【发布时间】:2018-03-02 14:03:38
【问题描述】:
我正在使用 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));
}
请帮我解决这个问题。
【问题讨论】:
标签: php laravel laravel-5 laravel-5.5