Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jbowman99's avatar

Login Event and Activity Log

I have created an Activity log that tracks creation, deletion and updating of articles. I would also like to track Login and logout events by users. so the log will also include username....logged in and username....logged out.

do i create new activities for this? or use the event handler to track this. I have seen and read the docs from L4, and L5 didn't know if it was the same for L5.1.

looking for a good place to start?

0 likes
1 reply
paradox's avatar

If you followed Jeffrey Way's way ;-) outlined in that two-part miniseries: https://laracasts.com/lessons/build-an-activity-feed-in-laravel then you should have by now trait that hooks up to your model events. As far as I remember he also used polymorphic relation table. Now what you need now is to hook up to the events you need to listen to:

  • auth.login - fired when user logged in successfully
  • auth.logout - fired when user logged out

And here in docs is an example how to make an event subscriber class: http://laravel.com/docs/5.1/events#event-subscribers All you need to do is make those listeners that insert a record to your "activity" table.

Please or to participate in this conversation.