gpt4 book ai didi

使用新模型和防护的 Laravel 身份验证失败 : Undefined index: model

转载 作者:行者123 更新时间:2023-12-03 15:44:41 26 4
gpt4 key购买 nike

我正在尝试使用额外的模型和防护来验证我的 Laravel 应用程序 (5.8)。问题,我在以下登录方法中收到“未定义索引:模型”错误。任何想法我做错了什么?我在 5.7 版本的 Laravel 中使用了这种集成,它在那里工作没有任何问题。

 auth()->guard('partner')->login($partner);

enter image description here

代码片段:

合作伙伴模型(附加设置)
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,
],
],

中间件组 (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,
],

];

路由服务提供者
  protected function mapPartnerRoutes()
{
Route::prefix('partner')
->middleware(['partner'])
->namespace($this->namespace)
->group(base_path('routes/partner.php'));

}

应用程序框架错误

enter image description here

最佳答案

我想你错过了在你的 partners 中配置一个模型身份验证提供者,即:

'partners' => [
'driver' => 'eloquent',
//'table' => \App\Models\Partner::class,
'model' => \App\Models\Partner::class,
],

关于使用新模型和防护的 Laravel 身份验证失败 : Undefined index: model,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55308874/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com