0
我得到這個錯誤:調用未定義的方法照亮身份驗證 TokenGuard ::嘗試()
Call to undefined method Illuminate\Auth\TokenGuard::attempt()
從這個代碼:
if(Auth::guard('admin')->attempt(['email' => $request->email, 'password' => $request->passsword], $request->remember)){
return redirect()->intended(route('admin.dashboard'));
}else{
我已經進口Illuminate\Support\Facades\Auth
as the docs suggest
我的auth.php
可能會幫助
<?php
return [
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
],
'admin' => [
'driver' => 'session',
'provider' => 'admins',
],
'admin-api' => [
'driver' => 'token',
'provider' => 'admins',
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
'admins' => [
'driver' => 'eloquent',
'model' => App\Admin::class,
],
],
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'expire' => 60,
],
'admins' => [
'provider' => 'admins',
'table' => 'password_resets',
'expire' => 15,
],
],
];
您的控制器中是否定義了Auth :: guard()方法?看起來它試圖使用api守衛之類的守衛,而不是你的管理員守衛。 –