Laravel 8 Multiple Authentication Example Tutorial

Laravel 8 Multiple Authentication Example Tutorial

Today, we are going to how to create multiple authentications using the laravel 8 (Laravel 8 Multiple Authentication Example).

Overview

Step 1: Install Laravel

Step 2: Setting Database Configuration

Step 3: Create Table using migration

Step 4: Install the Laravel/UI package

Step 5: Install the Laravel Auth command

Step 6: Create IsAdmin Middleware

Step 7: Modify the Controllers and Model

Step 8: Define The Route

Step 9: Create Blade Files

Step 10: Run Our Laravel Application

Step 1: Install Laravel

We are going to install laravel 8, so first open the command prompt or terminal and go to xampp htdocs folder directory using the command prompt. after then run the below command.

Step 2: Setting Database Configuration

After the complete installation of laravel. we have to database configuration. now we will open the .env file and change the database name, username, password in the .env file. See below changes in a .env file.

Step 3: Create Table using migration

Now, We need to update the user’s migration tables. so we will update the user’s migration table, see the below file to update the code for the users table.

Run the below command. after the changes above file.

Step 4: Install the Laravel/UI package

We need to laravel UI package so we will install the package using the below command.

when completed successfully installation of laravel UI package then we will see look like as below type of output.

Step 5: Install the Laravel Auth command

Now, we will install the laravel authentication using the below command.

here, Laravel extracted into a scaffolding separate laravel UI packages.

Step 6: Create Middleware

Now, we will create IsAdmin Middleware using the below command and we need some changes in handle method. so you can see the below code.

app/Http/Middleware/IsAdmin.php

After complete changes. we need to assign route on middleware array in the app/Http/Kernel.php file. so you can see the below code.

app/Http/Kernel.php

Step 7: Modify the controller and model

Now here, we need to add the adminHome() method in the HomeController.php file.

app/Http/Controllers/HomeController.php

And second, we need to update the LoginController.php file. so you can follow the below code.

app/Http/Controllers/Auth/LoginController.php

app/User.php

Step 8: Define The Route

We will open the web.php in the routes directory and paste below the following code.

Step 9: Create Blade Files

here in this step, we need to create a new adminHome.blade.php file or you can copy the file of home.blade.php and change the file name to the adminHome.blade.php.

adminHome.blade.php

Step 10: Run Our Laravel Application
We can start the server and run this example using the below command.

Now we will run our example using the below Url in the browser.

Download

Read Also
Laravel 8 CRUD Operation With Ajax Example

Laravel 8 Pagination Example Tutorial

Please follow and like us: