Last Login event registration

Today I worked on my application to record last login date and time for the users. After reading this documentation this is how I implemented in my project.

protected $listen = [
    'Illuminate\Auth\Events\Login' => [

Then ran the artisan command

php artisan event:generate

This artisan command generate events and listeners.
Then update the handle method under Listeners\LogLastLogin.php

public function handle(Login $event)
    $event->user->last_login = date('Y-m-d H:i:s');

Tested and its working fine. Happy days!!!

Leave a Reply

Your email address will not be published. Required fields are marked *