I have set the guard as admin like return Auth::guard('admin'). it can get data from the table 'admins' but after attempt Auth::user() return null
LoginController
===============
public function backendLogin(Request $request)
{
$this->validateLogin($request);
if ($this->hasTooManyLoginAttempts($request)) {
$this->fireLockoutEvent($request);
return $this->sendLockoutResponse($request);
}
if ($this->attemptLogin($request)) {
return $this->sendLoginResponse($request);
}
$this->incrementLoginAttempts($request);
return $this->sendFailedLoginResponse($request);
}
protected function guard()
{
return Auth::guard('admin');
}
config/auth.php
===============
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'admin' => [
'driver' => 'session',
'provider' => 'admins',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
'hash' => false,
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
'admins' => [
'driver' => 'eloquent',
'model' => App\Admin::class,
],
],
I have tried many type of
auth()->guard('admin')->attempt($credentials);
Auth::guard('admin')->attempt($credentials);
but still cannot login.
auth('admin')->attempt($credentials))auth::user('admin')->id?Auth::guard('admin')->user()