How to create an Admin-Panel in Laravel

In this, article we will discuss the creating an Admin Panel. As we know admin panel is one of the most important modules for your web or mobile application. In admin panel there is no role of application End users, only an Admin has the role to manage the application.

In this article, we have customized the admin panel and add some features such as: add new users, delete update users, login and signup page. If an Admin Login to an Admin Panel and do some activities like CRUD (create, read, update and delete) operations then activity should be created and should be available for Superuser to see.

How to create an Admin-Panel in Laravel?

1. Create Laravel Project

First you have to create a Laravel project using composer command:
“Composer create-project –prefer-dist laravel/laravel project_name”

2. Choose Performance Over Personalization

In this user have two options for designing user interface or download the free available theme for an admin panel. So many of designers download the theme and customize the theme as per user’s requirements. Downloading template will help to save time for creating the user interface.
So, in this article, I have downloaded the template and use their css, and java scripts file and customize the pages.

Steps for applying template in Laravel
2.1. First you have to download the template and after that copy the folder like css, js, scss, and image or assests folder. And go to your Laravel project directory and paste these assests folder in public directory of your laravel project.

2.2. Next, after copying the assets under the public directory, then we will create a master file under the “resources/view/layouts” directory. In this “master.blade.php” we have added and edit the template file code which has a user interface for the admin-panel. Then we will create a “dashboard.blade.php” file under the “resources/views/admin” folder, you can manually create the layouts and admin folder under these resources. This “dashboard.blade.php” file is used we have used for routing the dashboard of Admin panel.

master.blade.php file

dashboard.blade.php file

3. Database Connectivity

3.1. In this article, I have used the Wamp server for database. Go to the phpMyAdmin option in Wamp and create database look like:

3.2. Next, open “.env” and edit database connection look like:

4. Create Login Interface Using Authentication:

Laravel provide the authentication command for creating the login interface. Here we discussed how to setup an authentication for your project.
4.1. First run the artisan command in your terminal under your laravel project:
“php artisan make:auth”.

This command will create the authentication folder under “views/auth” directory.

4.2. After auth command, go to “database/migration/” and open file “create_user_table.php”. Under this file we have add two field “phone” and “usertype” field for admin panel.

4.3. After that, open file “register.blade.php” under the “resources/views/auth” and write code for adding the phone label field.

4.4. Next, we will modify the “User.php” file (“app/user.php”) and “RegiserController.php” file located at “app/http/Controller/auth/RegisterController.php”.

User.php

RegisterController.php

4.5. After modifying the files, run the migrate command:
“php artisan migrate”

After running this command, tables are created automatically in your database look like:

4.6. After migration, navigate the URL: http://127.0.0.1:8000 into your browser, and register the user.

Register User

Manually define usertype “admin” into your database
Then go to for middleware to redirect this admin into your dashboard.

5. Creating Middleware:

After completing the setup of dashboard, database and authentication setup add middleware for redirect to the admin dashboard.
5.1. Run the middleware command: “php artisan make:middleware middleware_name”

Next, go to directory “app/http/middleware/” and open “AdminMiddleware” file and write code look like:

5.2. Next, updated the “kernel.php” file under the “app/http/” directory:

5.3. Next, open the “LoginController.php” file under the “app/http/controller/auth” directory and add class and function like:

5.4. After the completion of middleware, route the dashboard using middleware in the Laravel. Open “web.php” file under the “routes” directory.

6. Login In Admin Panel

6.1. Open browser navigate the URL: http://127.0.0.1:8000/dashboard.

6.2. After navigating the URL, The login page will redirect after that enter the admin credentials:

6.3 After entering admin credentials, Dashboard page will open:

6.4. Logout

6.5. Register User’s

6.6. User’s Profile

6.7. Edit User’s by Admin

6.8. Delete User

Note: you can download the code form GitHub directory, link: https://github.com/digitalcrm/Admin-Dashboard.