Laravel 8 Multiple Authentication

In this tutorial you will learn about the Laravel 8 Multiple Authentication and its application with practical example.

In this Laravel 8 Multiple Authentication Tutorial I’ll show you how to create multiple authentication system in laravel 8. In this tutorial you will learn to create or implement multiple authentication in laravel. In this article we will be creating multiple authentication system using custom middleware in laravel 8. Multiple authentication system means to allow multiple users to login in one application according to their roles. In this example we will create a middleware for checking the user’s role whether it is an admin or normal user.

Laravel 8 Multiple Authentication

In this step by step Laravel 8 Multiple Authentication Example we will learn to implement multi auth system using middleware in laravel 8.

  1. Install Laravel Application
  2. Configure Database Connection
  3. Set Up Model and Run Migration
  4. Generate Auth Scaffolding
  5. Set Up Admin Middleware
  6. Set Up Route
  7. Configure Home Controller
  8. Configure Blade View
  9. Configure Login Controller
  10. Seed Database with User Data
  11. Run & Test The Laravel Multi Auth App
  12. The Bottom Line

Download Laravel Application

First of all we need to create a fresh laravel project, download and install Laravel 8 using the below command

Now switch inside the project directory using following command.

Configure Database Connection

Now, lets create a MySQL database and connect it with laravel application. After creating database we need to set database credential in application’s .env file.

Set Up Model and Run Migration

In this step we will declare the new property ‘is_admin’ in users table using migration. Put the following code inside database/migrations/timestamp_create_users_table.php file.

Now, get inside the app/User.php file and add the newly created is_admin property.

Now, run the migration to create database table using following artisan command:

Generate Auth Scaffolding

In this step we will Install Laravel UI package using following command,


Now, execute the below command on terminal for creating login, registration, forget password and reset password blade files:

Run following command to compile your fresh scaffolding.

Set Up Admin Middleware

In this step we will create middleware for checking the user’s role. It is an admin or normal user.


Open app/Http/middleware/IsAdmin.php and paste the following code.

You have to define the Admin middleware in app/Http/Kernel.php file, so paste the following code inside of $routeMiddleware array.

Set Up Route

In this step, we will create a route for admin and bind it with admin home page. Paste the following code in routes/web.php file.

Configure Home Controller

We have to incorporate the handleAdmin() method inside the HomeController class, open app/Http/Controllers/HomeController.php, and add the following code.

Configure Blade View

Open resources/views/home.blade.php file and put the following code in it.

Now, create and open resources/views/handleAdmin.blade.php file and add the code.

Configure Login Controller

Put the following code in app/Http/Controllers/Auth/LoginController.php file

Seed Database with User Data

Now use the following command to generate a seeder.

Go to database/seeds/DummyUsersSeeder.php file and insert the following data.

Run & Test The Laravel Multi Auth App

Now we are ready to run our example so lets start the development server using following artisan command –

Now, open the following URL in browser to see the output –

In this tutorial we have learn about the Laravel 8 Multiple Authentication and its application with practical example. I hope you will like this tutorial.