codefun / activitylog
Laravel Activity Log
v1.0.7
2024-08-07 03:21 UTC
Requires
- php: ^7.3|^8.0
README
- This package will automatically Observe your Model class and track every data manupulation history like create, update, delete.
- It will automatically store both record (Previous record and Current Record). Also it can show the diffrences between previous and updated record of Model information along with user record of who manupulated the data.
Installation Process
composer require codefun/activitylog
php artisan migrate
- Optionally use:
php artisan vendor:publish --tag=codefun_activity
Before Laravel 5.7
Add the following into your providers array on config\app.php
:
CodeFun\Activitylog\App\Providers\ActivityServiceProvider
then add This alias into alias array on config\app.php
:
"Activity" => CodeFun\Activitylog\Facade\Activity::class
Not necessary from Laravel 5.7 onwards
Publish Resource File
php artisan vendor:publish --tag=codefun_activity
By default codefun provides a basic blade file with bootstrap(v5) for viewing Activity Log and Log Details.
You can to customize this blade page design by publishing the blade file.
It can be located at resources/views/vendor/codefun/
How To Use?
Go to your Model and use the trait file:
use CodeFun\Activitylog\App\Component\Traits\ModelActivity;
class AnyModel extends Model
{
use ModelActivity;
}
If you want to set custom message while data manipulation, override this method inside your model as shown:
use CodeFun\Activitylog\App\Component\Traits\ModelActivity;
class AnyModel extends Model
{
use ModelActivity;
public function getDescriptionForEvent($event_name) : string{
return "Information has been ". $event_name;
}
}
How to Show Activity log Via Web Route and API Route
For API
- http:://base_url/api/activity-log/list
- http:://base_url/api/activity-log/view/{uuid}
For Web
- http:://base_url/activity-log