【发布时间】:2019-01-01 10:17:17
【问题描述】:
我使用 laravel 并使用 mltiple auth 进行连接。 我的验证码
if (Auth::guard('patient')->attempt(['email' => $email, 'password' => $password])) {
//if(Auth::attempt($request->only($field, 'password'))){
//put session
Session::put('key', $user->id);
//change le status en ligne
Patient::WHERE('id', Auth::patient()->id)->UPDATE(['status' => 1]);
//redirect url
return redirect('/users/profile')->with('success', 'Bienvenue '.$user->firstname.', vous êtes bien connecté');
}else{
return redirect('/users/login')->with('error', 'Email or username incorrect!');
}
在 auth.php 中,我有
'guards' => [
'user' => [
'driver' => 'session',
'provider' => 'users',
],
'patient' => [
'driver' => 'session',
'provider' => 'patients',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
],
],
执行后发现这个错误
BadMethodCallException 方法 Illuminate\Auth\SessionGuard::patient 不存在。
我的代码有什么问题?
【问题讨论】:
-
显示来自 auth.php 的提供者部分
-
@Ts8060 [code] 'providers' => [ 'users' => [ 'driver' => 'eloquent', 'model' => App\Models\Users::class, ], '患者' => [ '司机' => '雄辩的', '模型' => App\Models\Patient::class, ], ],
-
您的 Patient 类是否扩展了 Authenticatable 类?
-
@Ts8060 这是真正的课程
-
你试图在哪里执行这个保护代码?在控制器的哪个部分或其他任何地方?
标签: php laravel session laravel-5 eloquent