我正在使用 Laravel 5.5 并尝试为用户和管理员实现多重身份验证。当我尝试在浏览器中调用管理员登录表单时出现此错误。
错误 :
App\Exceptions\Handler::unauthenticated($request, App\Exceptions\AuthenticationException $exception) 的声明应该与 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));
}
请帮我解决这个问题。