Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
February 26, 2022 01:35 am GMT

Laravel 9 Tutorial 7


Laravel 9 Tutorial from the beginning:- https://www.youtube.com/playlist?list=PLLUtELdNs2ZYTlQ97V1Tl8mirS3qXHNFZ

In Part-7 of the Laravel 9 Tutorial, we will start working on Multi Authentication for our Laravel 9 Multi Vendor E-commerce Website. We will configure Guards for Admins, Sub Admins and Vendors and default Web Auth for Users.

We will also prevent the admin routes including the dashboard from unauthorized access. No one can able to access the admin dashboard and other admin modules without login into the admin panel. We will use Guards to protect the admin routes including the dashboard route.

We will follow the below steps to set Guards for Admin Panel / Admins.

1) Update Admin model:-
We will update the Admin model to set the protected guard variable for admin and set other variables as shown in the video. We will also extend the Admin class to Authenticatable.

2) Update auth.php file:-
We will update the auth.php file located at config\auth.php to set guards for admin to assign session in driver and admins in provider as shown in the video.

We will also set providers for admins to assign eloquent in driver and Admin class in the model.

3) Create Admin Middleware:-
Now we will create an Admin Middleware file by running the below command:-
php artisan make:middleware Admin

4) Update kernel.php file:-
Now we will update the kernel.php file located at app\http\ folder to register Admin middleware as global as shown in the video.

5) 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.

Also, include use Auth; at top of Admin Middleware file.

6) Update web.php file:-
Add admin middleware group and move admin dashboard route under it to protect it from unauthorised access.

Now no one can access the admin dashboard without login into the admin panel. We have used Guards to protect the admin routes including the dashboard route.

In the next video, we will work on admin login and logout functionality. We will register the admin guard every time when an admin logs in and destroy it every time when admin logged out from the admin panel.

Thanks for watching :)

Laravel 9 Tutorial (Create Multi-Vendor E-commerce Website) - https://www.youtube.com/playlist?list=PLLUtELdNs2ZYTlQ97V1Tl8mirS3qXHNFZ

Get Ready for Laravel 9 - https://www.youtube.com/playlist?list=PLLUtELdNs2ZYVb9lco6OnloSFyBLZU3tz

Click here to subscribe for Laravel & other updates - https://www.youtube.com/stackdevelopers

Popular Stack Developers Series that can help you:-

Laravel Tutorial for Beginners - https://www.youtube.com/playlist?list=PLLUtELdNs2ZaHaFmydqjcQ-YyeQ19Cd6u

GIT Tutorial for Beginners - https://www.youtube.com/playlist?list=PLLUtELdNs2ZZVQ-dLOMFWvmCCduzJ8c6R

Laravel API Tutorial - https://www.youtube.com/playlist?list=PLLUtELdNs2ZbcCsd4yAAiBU2L3ROREk8P

Laravel Interview Questions - https://www.youtube.com/playlist?list=PLLUtELdNs2ZbzB_1Jdp_yFcORwOfWP8RU

jQuery Tutorial - https://www.youtube.com/playlist?list=PLLUtELdNs2ZbMYoUA46GIonOH29KcjtxA

Laravel Basic E-commerce Series - https://www.youtube.com/playlist?list=PLLUtELdNs2ZY5drPxIWzpq5crhantlzp7

Laravel Dating Series - https://www.youtube.com/playlist?list=PLLUtELdNs2ZZrPUnxjlomErJfNvkyS6Hf

Join this channel to get the complete source code of all series:
https://www.youtube.com/channel/UCExO2i-tLU1NyVZD6zOJQlw/join

Follow Stack Developers on Social Media to get updates and resolve your queries
Like Facebook Page to get updates - http://facebook.com/stackdevelopers2/
Join Facebook Group to resolve your queries - http://facebook.com/groups/stackdevelopers
Follow on Instagram - https://www.instagram.com/stackdevelopers2/
Follow on GitHub - https://github.com/stackdevelopers

laravel9 #laravel9tutorial #laravel


Original Link: https://dev.to/stackdevelopers/laravel-9-tutorial-7-2h8c

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To