Laravel Loggable is a package for eloquent models, which will monitor the changes on the models and log. It supports two drivers: File and Database.
- High-configurable
- Two drivers (database and file)
- Possibillity to use two drivers at once
- Possibillity to select the columns for the model which should be logged
- Possibillity to select the actions for the model which should be logged (create, edit, delete)
- Facade-based structure to fetch the logs for specific model
- Much more
composer require alkhachatryan/laravel-loggable
php artisan vendor:publish --tag=loggable
php artisan migrate
Open the configuration file at /config/loggable.php
Set the driver whhich will log the model changes (can be both). However, it's recommended to use the database driver so you can fetch the logs in the future.
'driver' => 'database'
That's it!
class Post extends Model
{
/** Include the loggable trait */
use Loggable;
/** Specified actions for this model */
public $loggable_actions = ['edit', 'create', 'delete'];
/** Specified fields for this model */
public $loggable_fields = ['title', 'body'];
protected $fillable = ['title', 'body'];
}
Loggable::model('App\Post');
LoggableModel::whereModelName('App\Post')->orderBy('id', 'DESC')->paginate(10);
You can use the event Alkhachatryan\LaravelLoggable\Events\Logged in pair with your listeners.
Please see CHANGELOG for more information what has changed recently.
Tests!!! Tests!!! Tests!!!
If you discover any security-related issues, please email info@khachatryan.org instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.