Actually gaurd define how the system should store and retrieve information about your users.
You can find the file location in your config/auth.php file and you can configure.
There are mainly two gaurd one id "web" and another is "api" guard.
1) A web guard is the traditional cookie store - so that web guard instructs Laravel to store and retrieve session information.
2) The API guard, on the other hand, uses tokens. So you would use the API guard if you want to authenticate users and requests using an API token in the header (bearer) or query parameter.
There is no restiction on creating own guard.
Here is sample of creating own guard in laravel
Place the $guard in model like example :
app/Dealer.php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class Dealer extends Authenticatable
{
use Notifiable;
protected $guard = 'dealer';
}
config/auth.php
<?php
[...]
'guards' => [
[...],
'dealer' => [
'driver' => 'session',
'provider' => 'dealers',
],
],
'providers' => [
[...]
'writers' => [
'driver' => 'eloquent',
'model' => App\Dealer::class,
],
],
[...]
app/Http/Controllers/Auth/LoginController.php
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
[...]
use Illuminate\Http\Request;
use Auth;
use App\Dealer;
[...]
class LoginController extends Controller
{
[...]
public function __construct()
{
$this->middleware('guest:dealer')->except('logout'); // call here
}
[...]
}