Okay, guys.
So I think it's time that we create some kind of an admin panel that will let people add, edit and
delete posts, but also see the recent comments and recent posts, and we'll give you some kind of an
overview of the app.
So let's begin working on that.
Let's create an admin panel.
And the first step would be to create a separate layout.
Now I'd like to just copy the contents of this main layout and modify it slightly.
So let's create admin PHP file inside layouts folder and paste the contents of our main layout.
Let me change the title to dashboard.
Also the H1 header should be dashboard and let's change the links a little bit.
So the main page here would be let's call it Admin dashboard.
Then instead of posts, we're going to have manage posts.
Also the link is slash admin slash posts.
So there is no way someone cannot be authenticated and admin and access the admin panel.
That's why we don't need this conditional option and instead we should have.
Sorry, I've removed the wrong part.
We should keep the logout part and remove the login link.
Like this.
So we also display the content here and in the footer you can say my blog admin panel.
So in this video I would like us to at least create the main dashboard page that will display some basic
info about the system for the admins.
So in the controllers folder we're going to create a sub folder called admin.
This would contain the admin panel controllers and inside it right away let me make a dashboard controller.
So the namespace here is up controllers admin.
And this is a dashboard controller.
For now let's just have one single action here the index which will display some basic info about the
system.
So in the views folder we need a sub folder I think that would be an admin.
And here we're going to have sub folders for every single controller.
So this one is the dashboard one.
And inside it I'm going to create an index PHP file which will display some basic info about our system.
So for now, let's focus on displaying anything.
Let me just say welcome to the admin panel.
Now jump back to the dashboard controller and let's just render this page.
We need a view from the core namespace and we are rendering the template.
Name is admin dashboard index.
There is no data for now at least.
And we've got a different layout this time.
This is layouts admin.
Now I don't really remember if I had to use this layout prefix yes I did.
Okay, so that should be fine.
Now we need to add this page to the routes.
So let me add a comment here.
Let's add some kind of separation and say admin panel roots.
And in the router I'm just adding a get method that is slash admin dashboard.
And the controller here is the interesting thing is we can use the namespaces normally.
So I can do admin slash dashboard controller.
And the action is index.
So after adding this route let me jump to the main layout and let me add one other link.
So if the user is signed in I'm going to link to the admin dashboard.
Now later on we're going to have the part of the system called authorization.
So we're going to build a system where we also apart from checking if someone is authenticated we're
going to check if, well he can do things Whether he can go to an admin panel which would require the
admin privileges, but that's for later for now.
Let me just add this link and it would be for now, accessible to everyone who's authenticated.
So when I now jump to the admin panel we can see our welcome to the admin panel message and a different
layout.
As you see we've got some different links.
Some of them work, others don't.
Anyway basically I think we can see that this works fine.
Now with this I should add the middleware which is auth so that no one who is not authenticated would
not be able to access the admin panel later on.
As I've said, we're gonna be also requiring some special user privileges.
Anyway, we've just started.
So we've created another section of this website, and in the next video we're going to add some interesting
stats into this main page.