Laravel 6 Multiple Authentication Example Tutorial

Laravel 6 Multiple Authentication Example Tutorial

Today, we are going to how to create multiple authentications using the laravel 6 (like front-end login and register and back-end login and register).

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 1: Install Laravel

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

Step 2: Setting Database Configuration

After 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 users migration table. so we will update the users migration table, see below file in update the code for 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 below command.

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

Step 6: Create Middleware

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

app/Http/Middleware/IsAdmin.php

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

app/Http/Kernel.php

Step 7: Modify the controller and model

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

app/Http/Controllers/HomeController.php

And second we need to update the LoginController.php file. so you can follow 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 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 file of home.blade.php and change the file name to the adminHome.blade.php.

adminHome.blade.php

Download

Read Also
Laravel 6 CRUD (Create Read Update Delete) Tutorial For Beginners

Laravel 6 CRUD Operation With Ajax Example

Laravel 6 Pagination Example Tutorial

Please follow and like us: