mardi 24 juillet 2018

Session guard doesn't found

I use laravel and I use mltiple auth for the connection. My code in authentification

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!');
            }

In auth.php, I have

'guards' => [
    'user' => [
        'driver' => 'session',
        'provider' => 'users',
    ],

    'patient' => [
        'driver' => 'session',
        'provider' => 'patients',
    ],

    'api' => [
        'driver' => 'token',
        'provider' => 'users',
   ],
],

After execute, I found this error

BadMethodCallException Method Illuminate\Auth\SessionGuard::patient does not exist.

What is the wrong in my code?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire