divineomega / laravel-last-activity
Stores the last activity time of users within your Laravel application
Fund package maintenance!
DivineOmega
Installs: 7 579
Dependents: 0
Suggesters: 0
Security: 0
Stars: 16
Watchers: 5
Forks: 5
Open Issues: 3
Requires
- php: >=7.1
- laravel/framework: ^5.6|^6|^7|^8
Requires (Dev)
- orchestra/testbench: ^3.8
README
Stores the last activity time of users within your Laravel application
Installation
To install the Laravel Last Activity package, just run the following Composer command from the root of your project.
composer require divineomega/laravel-last-activity
Setup
This package requires you to register middleware within
your app\Http\Kernel.php
file. You will need add the
middleware to every middleware group you wish to monitor
activity for, as shown below.
protected $middlewareGroups = [ 'web' => [ /* ... other web middleware ... */ \DivineOmega\LaravelLastActivity\Http\Middleware\LastActivity::class ], 'api' => [ /* ... other api middleware ... */ \DivineOmega\LaravelLastActivity\Http\Middleware\LastActivity::class ], ];
You also need to add the config file and migration to your project. To do so, simply run the following Artisan command.
php artisan vendor:publish --provider="DivineOmega\LaravelLastActivity\ServiceProvider"
You can then run the provided migration to add a last_activity
field
to your users
table.
php artisan migrate
That's it. The last_activity
field within your users
will be
automatically updated whenever the user interacts with your application
via the web or API.
Alternative field name
If you do not wish to use last_activity
as the field name, this
can be changed in the provided migration. You will also need
to alter the configuration file
The published configuration file for this package can be found at
config/last-activity.php
.
<?php return [ // Field in which the last activity date time will be stored. 'field' => 'last_activity', ];