Laravel Authentication Logs
Published on by Paul Redmond
Laravel Authentication Log is a package that tracks your user's authentication information such as login/logout time, IP, Browser, Location, etc., as well as sends out notifications via mail, slack, or SMS for new devices and failed logins.
If you've ever received new login notifications for services such as Netflix, this is an excellent way to keep users informed when new logins occur. At the time of writing, this package has notifications for new device logins and failed login attempts.
AuthenticationLoggable trait provided by the package, you'll get the following API to access authentication logs:
$user = User::find(1);// Get all authentication logs for a user$user->authentications;// Last login details$user->lastLoginAt();$user->lastSuccessfulLoginAt();$user->lastLoginIp();$user->lastSuccessfulLoginIp();// Previous login (excluding current login)$user->previousLoginAt();$user->previousLoginIp();