我正在使用 Laravel 5.5 并尝试为用户和管理员实现多重身份验证。当我尝试在浏览器中调用管理员登录表单时出现此错误。
错误:
Declaration of App\Exceptions\Handler::unauthenticated($request, App\Exceptions\AuthenticationException $exception) should be compatible with Illuminate\Foundation\Exceptions\Handler::unauthenticated($request, Illuminate\Auth\AuthenticationException $exception)
这是我在 app/Exceptions/Handler
中未经身份验证的函数:
protected function unauthenticated($request, AuthenticationException $exception)
{
if ($request->expectsJson()) {
return response()->json(['error' => 'Unauthenticated.'], 401);
}
$guard = array_get($exception->guards(), 0);
switch ($guard) {
case 'admin':
$login = 'admin.login';
break;
default:
$login = 'login';
break;
}
return redirect()->guest(route($login));
}
请帮我解决这个问题。
最佳答案
您忘记在文件顶部添加 use Illuminate\Auth\AuthenticationException
关于php - 处理程序类错误 - Laravel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46340198/