cybernerdie / laravel-model-activity-log
A simple package to log model activities inside your laravel application
Requires
- php: ^8.0
- illuminate/support: ^8.0|^9.0
- spatie/laravel-package-tools: ^1.6
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2024-10-24 12:41:10 UTC
README
This package logs model activities inside your Laravel application.
Installation
You can install the package via composer:
composer require cybernerdie/laravel-model-activity-log
You can publish the migrations with:
php artisan vendor:publish --provider="Cybernerdie\\ModelActivityLog\\ModelActivityLogServiceProvider"
You can run the migrations with:
php artisan migrate
Usage
Add the trait to your model and also import the class:
use RecordModelActivity;
Optionally, you can set the events to be recorded for your model:
protected static $eventsToRecord = ['created', 'updated'];
Optionally, you can add columns in your model that you want to ignore when events are recorded:
protected static $columnsToIgnore = ['email'];
Retrieve activities for a model:
$user = User::find(1); $activities = ModelActivityLog::subjectBy($user)->get();
Retrieve activities by event type:
$activities = ModelActivityLog::event('created')->get();
Retrieve changes for a specific activity:
$activities = ModelActivityLog::find(1)->changes();
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.