lundi 5 septembre 2016

Laravel 5.1 Event Listener Error

I have the following event listner and subscriber:

class UserEventListener
{
    public function onUserLogin(User $user, $remember) {

        $user->last_login_at = Carbon::now();

        $user->save();
    }

    public function onUserLogout(User $user) {}

    public function subscribe($events)
    {
        $events->listen(
            'auth.login',
            'App\Listeners\UserEventListener@onUserLogin'
        );

        $events->listen(
            'auth.logout',
            'App\Listeners\UserEventListener@onUserLogout'
        );

    }
}

When I logout I get the following error:

Argument 1 passed to App\Listeners\UserEventListener::onUserLogout() must be an instance of App\User, null given

The documentation states that on the auth.logout event, parameter $user is available - refer to the section on Framework Event

So why I'm I getting this error?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire