laravel-audit-trails maintained by aaix
Description
Lightweight audit-trail package for Laravel — logs created, updated, deleted, restored and force-deleted Eloquent events.
Author
Last update
2026/08/27 22:50
(dev-main)
License
Downloads
29
Installation
composer require aaix/laravel-audit-trails
# Publish the migrations
php artisan vendor:publish --tag="audit-trails-migrations"
php artisan migrate
# Optional
php artisan vendor:publish --tag="audit-trails-config"
Quick start
use Aaix\LaravelAuditTrails\Concerns\TracksAuditTrail;
class Order extends Model
{
use TracksAuditTrail;
}
Derive columns from the audited record
Each audit row is saved with the audited model attached as a loaded auditable relation, so a creating hook can denormalise a column onto the row without a lookup:
class AuditTrail extends BaseAuditTrail
{
protected static function booted(): void
{
static::creating(function (self $trail): void {
$trail->tenant_id = $trail->auditable?->tenant_id;
});
}
}
Don't query by auditable_id instead: deleted fires after the DELETE, so for a model without SoftDeletes the record is already gone and a NOT NULL column fails the insert. The attached instance works for every action, deletes included.
Documentation
Full documentation: jonaaix.github.io/laravel-audit-trails
License
MIT — see LICENSE.md.