Laravel 5.1事件监听器错误

时间:2016-09-05 20:08:31

标签: php laravel-5.1 event-listener

我有以下活动列表和订阅者:

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

    }
}

当我退出时,我收到以下错误:

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

文档说明在auth.logout事件中,参数$ user可用 - 请参阅Framework Event

部分

那我为什么会收到此错误?

0 个答案:

没有答案