frengky / laravel-auditable
Laravel Eloquent Model Auditing
dev-main
2021-03-31 08:08 UTC
Requires
- php: ^7.2.5|^8.0
Requires (Dev)
- illuminate/database: ^7|^8
- illuminate/support: ^7|^8
This package is auto-updated.
Last update: 2025-03-01 00:34:45 UTC
README
Introduction
This package help audit model data changes, during create, update, and deleting (audit trail)
Installation
- Installing the package
$ composer require frengky/laravel-auditable
- Add the service provider to your
config/app.php
Frengky\Auditable\ServiceProvider::class
Usage
Use the Auditable
trait to your model:
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class YourModel extends Model { use Frengky\Auditable\Auditable; } ?>
Now you can call the trait method, everytime you make changes with your model:
// After creating new record $yourModel = YourModel::create(['title' => 'Foo']); $yourModel->auditCreating(); // Before saving updated record $yourModel->auditUpdating(); $yourModel->save(); // After deleting a record $yourModel->destroy($id); $yourModel->auditDeleting();