我有以下活动列表和订阅者:
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
部分那我为什么会收到此错误?