我正在尝试使用其他模型和防护对我的Laravel应用程序(5.8)进行身份验证。问题是,在以下登录方法期间,我收到“未定义索引:模型”错误。任何想法我在做什么错?我已经在5.7版本的Laravel中使用了此集成,并且在该版本中没有任何问题。
auth()->guard('partner')->login($partner);
代码段:
合作伙伴模型(其他设置)
class Partner extends Authenticatable {
protected $guard = 'partner';
public function getRouteKeyName()
{
return 'uuid';
}
}
警卫队(config.auth.php)
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'partner' => [
'driver' => 'session',
'provider' => 'partners',
],
],
提供商(config.auth.php)
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],
'partners' => [
'driver' => 'eloquent',
'table' => \App\Models\Partner::class,
],
],
中间件Gorup (kernel.php)
protected $middlewareGroups = [
'partner' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
//\Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
],
];
RouteServiceProvider
protected function mapPartnerRoutes()
{
Route::prefix('partner')
->middleware(['partner'])
->namespace($this->namespace)
->group(base_path('routes/partner.php'));
}
应用框架错误
答案 0 :(得分:2)
我认为您想在partners
身份验证提供程序中配置模型,即:
'partners' => [
'driver' => 'eloquent',
//'table' => \App\Models\Partner::class,
'model' => \App\Models\Partner::class,
],