odinbi / activity-logs-with-trigger
Write activity logs use tringger
v1.6
2025-01-02 03:27 UTC
Requires
- php: >=7.0
- illuminate/support: ^5.8|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
README
Record query history of table in mysql
User Manual
Install package
composer require odinbi/activity-logs-with-trigger
Publish vendor
php artisan vendor:publish --tag=odb-activity-log
Migrate datatable
Run php artisan migrate command to create activity_log_triggers table
php artisan migrate
Or run with folder path option
php artisan migrate --path=database/migrations/2024_01_01_000000_create_activity_log_triggers_table.php
Configuration
Go to app/config/activity-logs-trigger.php to configure the necessary variables
- table:
List of tables to record history
- middleware_groups:
Using middleware for web or api
- retain_days:
Maximum log retention time in days
Schedule
Configure automatic schedule to delete old logs according to retain days, EX:
$schedule->command('logs:clean-old')->dailyAt('01:00');
Command
Create triggers for all tables defined in activity-logs-trigger
php artisan db:create-all-triggers
Add a trigger to any table, php artisan db:create-triggers
. For example to the users tablephp artisan db:create-triggers users