wamesk / laravel-user-activity
There is no license information available for the latest version (1.0.0) of this package.
1.0.0
2023-11-09 14:50 UTC
Requires
- php: ^8.1|^8.2
- laravel/framework: ^9.0|^10.0
This package is auto-updated.
Last update: 2025-01-09 08:58:18 UTC
README
This package is responsible for logging user activity in user_activities table after every api call.
User must be authorized.
User activity will be logged once per day but will hold exact time of first activity.
Setup
composer require wamesk/laravel-user-activity
Add service provider to array of providers in config/app.php
'providers' => [ ... /* * Third Party Service Providers... */ \Wame\LaravelUserActivity\UserActivityServiceProvider::class, ];
Run vendor:publish
php artisan vendor:publish --provider=Wame\LaravelUserActivity\UserActivityServiceProvider
If needed, change package configuration in config/laravel-user-activity
return [ 'user_class' => 'App\\Models\\User', 'user_table_name' => 'users', 'table_name' => 'user_activities', 'user_id_type' => 'ulid', // id / ulid / uuid ];
Run migrations
php artisan migrate
Add UserActivityTrait
in your User model
class User extends Models { ... use \Wame\LaravelUserActivity\Traits\UserActivityTrait; ... }
Register UserActivity
middleware in Kernel.php
protected $routeMiddleware = [ ... 'user.activity' => \Wame\LaravelUserActivity\Http\Middleware\UserActivity::class, ];
Apply user.activity
middleware in your routes/api.php
Route::group(['middleware' => 'user.activity'], function () { }