login event handling in laravel 5

后端 未结 8 2520
温柔的废话
温柔的废话 2020-12-05 11:46

i am trying to hook to the login even in my L5 app to set last login time and IP address. i can make it work with the following:

Event::listen(\'auth.login\'         


        
8条回答
  •  青春惊慌失措
    2020-12-05 11:54

    Open up EventServiceProvider.php and in boot method you can listen for 'auth.login' event via callback.

    public function boot(DispatcherContract $events)
    {
        parent::boot($events);
        $events->listen('auth.login', function() 
        {
            dd('logged in event');
        });
    }
    

    You may want to create listener so you move callback function somewhere else. Do that following this http://laravel.com/docs/4.2/events#using-classes-as-listeners

提交回复
热议问题