我还阅读了有关错误的其他问题,因此我重新检查了代码,未发现任何错字, 错误
Symfony \组件\调试\异常\ FatalThrowableError(E_RECOVERABLE_ERROR) 传递给Illuminate \ Auth \ SessionGuard :: __ construct()的参数2必须实现Illuminate \ Contracts \ Auth \ UserProvider接口,给定为null,在第125行的\ vendor \ laravel \ framework \ src \ Illuminate \ Auth \ AuthManager.php中调用< / p>
Auth.php
return [
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
'hash' => false,
],
'admin' => [
'driver' => 'session',
'provider' => 'admin',
],
'user' => [
'driver' => 'session',
'provider' => 'user',
],
'company' => [
'driver' => 'session',
'provider' => 'company',
],
'employee' => [
'driver' => 'session',
'provider' => 'employee',
],
],
'providers' => [
'admin' => [
'driver' => 'eloquent',
'model' => App\Admin::class,
],
'company' => [
'driver' => 'eloquent',
'model' => App\Model\Employee::class,
],
'employee' => [
'driver' => 'eloquent',
'model' => App\Model\Employee::class,
],
],
];
答案 0 :(得分:0)
一切都很好,我只是在控制器中被称为旧的默认用户身份验证,我在旧项目中进行了修改,现在我安装了新项目,然后移动了除user.php默认模型之外的所有文件
$companyAuth = auth()->guard('user'); //called wrong default
$companyAuth = auth()->guard('employee'); //now working fine
答案 1 :(得分:0)
您需要为新警卫定义提供程序,否则它将引发错误。当您引用管理员
的特定迁移表时,您的提供者也应拼写为“管理员”'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
'admins' => [
'driver' => 'eloquent',
'model' => App\Admin::class,
],
],