Introduction

Laravel's events provides a simple observer implementation, allowing you to subscribe and listen for various events that occur in your application. Events serve as a great way to decouple various aspects of your application, since a single event can have multiple listeners that do not depend on each other. So, we'll use Laravel Events to log each user's login information.

When logging in to a Laravel application, we usually needs to enter email and password. However, there was a client asked to make the login works with either email or username. After digging around, it turns out to be an easy task. How is it possible?