login event handling in laravel 5

后端 未结 8 2516
温柔的废话
温柔的废话 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:57

    just did it this way

        listen('auth.login', function() 
            {
    
                DB::table('users')
                    -> where('id', Auth::id())
                    -> update(array(
                            'last_login'    => date('Y-m-d H:i:s')
                        ));
    
            });
    
            //
        }
    }
    

提交回复
热议问题