• Save

How to Add an Admin Side in Laravel Project

Thanks to Alexander J Curtis for his tutorial that shed more light on how this functionality can be achieved. Adding an admin side in older version of Laravel works greats(Laravel 5.4 and lover), but moving the newer versions, the app tends to create bugs when setting up guard for the admin side based off of the user side.

This short tutorial is an improvement over the earlier tutorial by Alex and I suggest you see his tutorial (Multiple Authentication in Laravel 5.4) before trying the steps I have explained in here.

Step 1:

Create the default authentication for user side

Step 2:

Duplicate the user model(User.php) as Admin.php with the following code content

Step 3:

Set-up guard for the admin side in the config/auth.php file. The auth.php file will contains guards for the user and admin as follows:

Step 4:

Create a Login Controller for the admin side (AdminLoginController.php) as follows

Step 5:

Create a new controller for the Admin side of the system (AdminController.php). Only authenticated admin has access to this route. For example, only an authenticated user has access to the admin dashboard.

In these 5 simple steps, you can create a admin dashboard. I have tried this in two different project and it works great. If you face any problems, try to clear with the following command:




Hard work | Dedication | Commitment

Leave a Reply

Your email address will not be published. Required fields are marked *