Using the rajpurohit-dinesh example, we just need to finish the first step:
1: Create the App \ Admin model (in our application folder). This is how your Authenticatable class should be.
<?php namespace App; use Illuminate\Foundation\Auth\User as Authenticatable; Class Admin extends Authenticatable {
2: update the configuration /auth.php.
return [ // This is the default guard used, not need to declare // another guard here 'defaults' => [ 'guard' => 'user', 'passwords' => 'user', ], // Here we must to declare the guards, if we created the App\Admin // class as first step, we don't need to create a custom guard 'guards' => [ 'user' => [ 'driver' => 'session', 'provider' => 'user', ], 'admin' => [ 'driver' => 'session', 'provider' => 'admin', ], ], // In this example we are using only 'eloquent' driver 'providers' => [ 'user' => [ 'driver' => 'eloquent', 'model' => 'App\User', ], 'admin' => [ 'driver' => 'eloquent', 'model' => 'App\Admin', ], ], 'passwords' => [ 'user' => [ 'provider' => 'user', 'email' => 'auth.emails.password', 'table' => 'password_resets', 'expire' => 60, ], 'admin' => [ 'provider' => 'admin', 'email' => 'auth.emails.password', 'table' => 'password_resets', 'expire' => 60, ] ] ];
3: To test this, we can use our application file \ Http \ Route.php:
Route::get('/login', function() { $auth = auth()->guard('admin'); $credentials = [ 'email' => 'admin@gmail.com', 'password' => 'password', ]; if ($auth->attempt($credentials)) { return 'Success'; } else { return 'Not Success'; });