salfade / laravel-login-tracker
A simple package to track users successful login attempts
Installs: 2 061
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 3
Forks: 3
Open Issues: 1
Requires
- php: ^7.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
- orchestra/testbench: ^5.0
- phpunit/phpunit: ^9.0
- psalm/plugin-laravel: ^1.2
- vimeo/psalm: ^3.11
README
This simple package let's you track your user login activity. Track their IPs to give you better visibility to see user activity.
Support us
Installation
composer require salfade/laravel-login-tracker
Publish and run the migrations with:
php artisan vendor:publish --provider="Salfade\LoginTracker\LoginTrackerServiceProvider" --tag="migrations" php artisan migrate
Next, add the Salfade\LoginTracker\Traits\HasLoginAttempts
trait to your User
Model.
use Salfade\LoginTracker\Traits\HasLoginAttempts;
Usage
Retrieving the latest successful login attempt
$userLastSuccessfulLogin = User::find($id)->latestLoginAttempt(); echo $userLastSuccessfulLogin->ip_address; echo $userLastSuccessfulLogin->created_at;
Retrieving all the successful login attempts
$userLastSuccessfulLogin = User::find($id)->loginAttempts();
Retrieving the IP address of last successful login attempt
$userLastSuccessfulLogin = User::find($id)->lastLoginIp();
Retrieving the timestamp of last successful login attempt
$userLastSuccessfulLogin = User::find($id)->lastLoginDate();
Retrieving the human friendly date for last successful login attempt
$userLastSuccessfulLogin = User::find($id)->lastLoginDateForHuman();
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email admin@salfade.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.