kamel/laravel-auditable is a Laravel package.
It currently has 0 GitHub stars and 6 downloads on Packagist (latest version v0.1.0).
Install it with composer require kamel/laravel-auditable.
Discover more Laravel packages by kamel
or browse all Laravel packages to compare alternatives.
Last updated
A Laravel package that provides automatic auditing for Eloquent models.
composer require kamel/laravel-auditable
Add the Auditable trait to any Eloquent model:
<?php
namespace App\Models;
use Kamel\Auditable\Traits\Auditable;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
use Auditable;
protected $fillable = ['name', 'email', 'password'];
}
Once the trait is added, all Eloquent operations are automatically audited:
// Creating a user - triggers audit
$user = User::create([
'name' => 'John Doe',
'email' => '[email protected]'
]);
// Updating a user - triggers audit
$user = User::find(1);
$user->name = 'Jane Doe';
$user->save();
// Mass update - triggers audit
User::where('id', 1)->update(['email' => '[email protected]']);
The package dispatches AuditWasTriggered events. Listen for them.
Each audit record contains:
model_type: The audited model classmodel_id: The model's primary keyold_values: JSON of previous valuesnew_values: JSON of new valuesuser_type: User model class (if authenticated)user_id: User ID (if authenticated)url: Request URLmake build
make test
make clean
make build - Build the Docker containermake test - Run the test suite with testdox outputmake clean - Remove Docker containers and images