jeudi 25 février 2016

Laravel 5: The difference between Auth::guard($this->getGuard())->login($user); and auth()->login($user);

What is the difference between:

Auth::guard($this->getGuard())->login($user);

and

auth()->login($user);

? For example, in PasswordController.php we can have:

protected function resetPassword($user, $password)
{
    $user->password = $password;

    $user->save();

    Auth::guard($this->getGuard())->login($user);
}

or

protected function resetPassword($user, $password)
{
    $user->password = $password;

    $user->save();

    auth()->login($user);
}

(in this case, we create a mutator in Users.php to bcrypt password AND NOT in resetPassword($user, $password) as it is by default)

In particular, what is guard($this->getGuard()), what does it do (guard(), getGuard())?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire