filmov
tv
#5 Make Advance E-com Website in Laravel 6.0 | Multi Auth | Guards for Admin | Auth for Users

Показать описание
In Part-5, we will start working on Multi Authentication for our Advance E-com website in Laravel 6. We will use Guards for Admins and default Laravel Auth for Users.
We will follow below steps to set Guards for Admin Panel / Admins.
1) Create Migration File
First of all, we will create migration file with name create_admins_table for creating admins table with below columns :-
id, name, type, mobile, email, email_verified_at, password, image, status
So, we will run below artisan command to create migration file for admins :-
php artisan make:migration create_admins_table
Open create_admins_table migration file and add all required columns mentioned earlier.
Now we will run below artisan command to create admins table with required columns :-
php artisan migrate
2) Create Admin model :-
Now we will create Admin model with below artisan command :-
php artisan make:model Admin
We will update content of Admin model file to set protected guard variable for admin and set other variables as shown in video.
We will also extends Admin class to Authenticatable and add its namespace as well.
We will also set providers for admins to assign eloquent in driver and Admin class in model.
4) Create Admin Middleware :-
Now we will create Admin Middleware file by running below command :-
php artisan make:middleware Admin
6) Update Admin Middleware
Add Auth:guard check in Admin Middleware to protect the admin routes. This check will be false for now as we have not registered the admin guard yet.
Add admin middleware group and move admin dashboard route under it to protect it from unauthorised access.
Now no one can access admin dashboard without login into the admin panel. We have used Guards to protect the admin routes including dashboard route.
In next video, we will work on admin login and logout functionality. We will register admin guard every time when admin logged in and destroy it every time when admin logged out from the admin panel.
Thanks for watching :)
We will follow below steps to set Guards for Admin Panel / Admins.
1) Create Migration File
First of all, we will create migration file with name create_admins_table for creating admins table with below columns :-
id, name, type, mobile, email, email_verified_at, password, image, status
So, we will run below artisan command to create migration file for admins :-
php artisan make:migration create_admins_table
Open create_admins_table migration file and add all required columns mentioned earlier.
Now we will run below artisan command to create admins table with required columns :-
php artisan migrate
2) Create Admin model :-
Now we will create Admin model with below artisan command :-
php artisan make:model Admin
We will update content of Admin model file to set protected guard variable for admin and set other variables as shown in video.
We will also extends Admin class to Authenticatable and add its namespace as well.
We will also set providers for admins to assign eloquent in driver and Admin class in model.
4) Create Admin Middleware :-
Now we will create Admin Middleware file by running below command :-
php artisan make:middleware Admin
6) Update Admin Middleware
Add Auth:guard check in Admin Middleware to protect the admin routes. This check will be false for now as we have not registered the admin guard yet.
Add admin middleware group and move admin dashboard route under it to protect it from unauthorised access.
Now no one can access admin dashboard without login into the admin panel. We have used Guards to protect the admin routes including dashboard route.
In next video, we will work on admin login and logout functionality. We will register admin guard every time when admin logged in and destroy it every time when admin logged out from the admin panel.
Thanks for watching :)
Комментарии