skyosev / login-activity-log
Track users login activity for Laravel 5.5+
Installs: 1 044
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: >=7.2
- laravel/framework: ~5.5.0|~5.6.0|~5.7.0|~5.8.0|~6.0|~7.0|^8.0
This package is auto-updated.
Last update: 2024-05-13 16:15:24 UTC
README
This package will subscribe for login and logout events and will log data every time they are fired. The log target can be the database or the default Laravel log handler.
Requirements
Laravel Framework > 5.5
Installation
In terminal
composer require skyosev/login-activity-log
Publish migrations
php artisan vendor:publish --provider="Kiva\LoginActivity\LoginActivityServiceProvider" --tag="migrations" php artisan migrate
Optionally publish config
php artisan vendor:publish --provider="Kiva\LoginActivity\LoginActivityServiceProvider" --tag="config"
Usage
Once installed, the package will begin to store logs automatically in the appropriate target (database by default). There is also a simple repository implementation with several methods for logs retrieval from database. You can use the Kiva\LoginActivity\Facades\LoginActivityRepository facade to access them:
Get latest logs
$logs = LoginActivityRepository::getLatestLogs(100); // number of logs to get (leave empty to use the config value)
Get latest login logs
$logs = LoginActivityRepository::getLatestLoginLogs(100); // number of logs to get (leave empty to use the config value)
Get latest logout logs
$logs = LoginActivityRepository::getLatestLogoutLogs(100); // number of logs to get (leave empty to use the config value)
Clean log
$logs = LoginActivityRepository::cleanLog(30); // Offset in days
Clean the log from terminal
php artisan login-activity:clean