Multi-Auth and Multi-Guard in Laravel 10

• Enter following commands to create the necessary files.

php artisan make:model Admin -mc
php artisan make:middleware Admin
php artisan make:seeder AdminSeeder

• Edit the app/Http/Kernel.php file and add the following line as a value in protected $middlewareAliases

'admin' => \App\Http\Middleware\Admin::class,

• Edit the config/auth.php file and add the following lines as a value in guards and providers respectively

// guards
'admin' => [
     'driver' => 'session',
     'provider' => 'admins',
],

// providers
'admins' => [
     'driver' => 'eloquent',
     'model' => App\Models\Admin::class,
],

Please watch the following playlist for better understanding.

Similar Posts