WEBVTT

00:00.470 --> 00:01.130
Okay, guys.

00:01.130 --> 00:09.320
So I think it's time that we create some kind of an admin panel that will let people add, edit and

00:09.320 --> 00:17.180
delete posts, but also see the recent comments and recent posts, and we'll give you some kind of an

00:17.180 --> 00:19.280
overview of the app.

00:19.370 --> 00:22.520
So let's begin working on that.

00:22.520 --> 00:25.520
Let's create an admin panel.

00:25.520 --> 00:30.020
And the first step would be to create a separate layout.

00:30.710 --> 00:37.670
Now I'd like to just copy the contents of this main layout and modify it slightly.

00:37.730 --> 00:47.660
So let's create admin PHP file inside layouts folder and paste the contents of our main layout.

00:49.010 --> 00:52.580
Let me change the title to dashboard.

00:53.690 --> 01:00.830
Also the H1 header should be dashboard and let's change the links a little bit.

01:00.830 --> 01:07.580
So the main page here would be let's call it Admin dashboard.

01:11.950 --> 01:17.530
Then instead of posts, we're going to have manage posts.

01:18.100 --> 01:21.580
Also the link is slash admin slash posts.

01:23.320 --> 01:31.180
So there is no way someone cannot be authenticated and admin and access the admin panel.

01:31.210 --> 01:38.290
That's why we don't need this conditional option and instead we should have.

01:38.320 --> 01:40.000
Sorry, I've removed the wrong part.

01:40.030 --> 01:44.740
We should keep the logout part and remove the login link.

01:47.110 --> 01:48.430
Like this.

01:48.460 --> 01:59.020
So we also display the content here and in the footer you can say my blog admin panel.

02:02.140 --> 02:08.710
So in this video I would like us to at least create the main dashboard page that will display some basic

02:08.710 --> 02:12.370
info about the system for the admins.

02:12.520 --> 02:18.550
So in the controllers folder we're going to create a sub folder called admin.

02:18.640 --> 02:27.850
This would contain the admin panel controllers and inside it right away let me make a dashboard controller.

02:31.330 --> 02:37.690
So the namespace here is up controllers admin.

02:38.710 --> 02:43.690
And this is a dashboard controller.

02:44.200 --> 02:53.740
For now let's just have one single action here the index which will display some basic info about the

02:53.740 --> 02:54.700
system.

02:55.210 --> 03:01.540
So in the views folder we need a sub folder I think that would be an admin.

03:01.540 --> 03:07.420
And here we're going to have sub folders for every single controller.

03:07.630 --> 03:12.040
So this one is the dashboard one.

03:12.040 --> 03:22.740
And inside it I'm going to create an index PHP file which will display some basic info about our system.

03:25.140 --> 03:28.710
So for now, let's focus on displaying anything.

03:28.710 --> 03:34.740
Let me just say welcome to the admin panel.

03:36.690 --> 03:42.900
Now jump back to the dashboard controller and let's just render this page.

03:42.930 --> 03:49.770
We need a view from the core namespace and we are rendering the template.

03:49.800 --> 03:54.840
Name is admin dashboard index.

03:55.770 --> 03:58.110
There is no data for now at least.

03:58.110 --> 04:00.840
And we've got a different layout this time.

04:00.990 --> 04:04.590
This is layouts admin.

04:07.110 --> 04:13.410
Now I don't really remember if I had to use this layout prefix yes I did.

04:13.440 --> 04:17.160
Okay, so that should be fine.

04:17.340 --> 04:21.660
Now we need to add this page to the routes.

04:22.470 --> 04:24.660
So let me add a comment here.

04:25.320 --> 04:31.970
Let's add some kind of separation and say admin panel roots.

04:34.460 --> 04:44.540
And in the router I'm just adding a get method that is slash admin dashboard.

04:45.500 --> 04:52.850
And the controller here is the interesting thing is we can use the namespaces normally.

04:52.850 --> 04:58.490
So I can do admin slash dashboard controller.

04:58.490 --> 05:01.700
And the action is index.

05:01.910 --> 05:11.120
So after adding this route let me jump to the main layout and let me add one other link.

05:11.120 --> 05:20.690
So if the user is signed in I'm going to link to the admin dashboard.

05:20.840 --> 05:27.710
Now later on we're going to have the part of the system called authorization.

05:27.710 --> 05:33.440
So we're going to build a system where we also apart from checking if someone is authenticated we're

05:33.440 --> 05:40.580
going to check if, well he can do things Whether he can go to an admin panel which would require the

05:40.580 --> 05:44.450
admin privileges, but that's for later for now.

05:44.720 --> 05:52.910
Let me just add this link and it would be for now, accessible to everyone who's authenticated.

05:53.510 --> 06:01.400
So when I now jump to the admin panel we can see our welcome to the admin panel message and a different

06:01.400 --> 06:01.850
layout.

06:01.850 --> 06:05.000
As you see we've got some different links.

06:05.000 --> 06:07.370
Some of them work, others don't.

06:07.400 --> 06:12.440
Anyway basically I think we can see that this works fine.

06:12.530 --> 06:21.380
Now with this I should add the middleware which is auth so that no one who is not authenticated would

06:21.380 --> 06:25.760
not be able to access the admin panel later on.

06:25.760 --> 06:31.280
As I've said, we're gonna be also requiring some special user privileges.

06:31.280 --> 06:34.070
Anyway, we've just started.

06:34.070 --> 06:41.120
So we've created another section of this website, and in the next video we're going to add some interesting

06:41.120 --> 06:44.120
stats into this main page.
