in my project I have two guards, the first is "web" related to admins table with session driver, and the second one is "mobile" related to users table with token driver.
'defaults' => [
'guard' => 'web',
'passwords' => 'admins',
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'admins',
],
'mobile' => [
'driver' => 'token',
'provider' => 'users',
],
],
Note: I am using sanctum authentication system.
so I am trying to log in using the second guard and when I attempt credentials, an error occurs:
public function login(Request $request)
{
.............
if(!Auth::guard('mobile')->attempt($request->only(['email', 'password']))){
return response()->json([
'status' => false,
'message' => 'Email & Password does not match with our record.',
], 401);
}
.............
}
the error:
"Call to undefined method Illuminate\Auth\TokenGuard::attempt()"
So how can I check the credentials of non-default guard, or if there is any suggestion ?