skyosev/login-activity-log

Track users login activity for Laravel 5.5+

1.0.3 2020-09-13 05:51 UTC

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

Credits

License

MIT - http://opensource.org/licenses/MIT