Search by

aaix / laravel-audit-trails

aaix

Lightweight audit-trail package for Laravel — logs created, updated, deleted, restored and force-deleted Eloquent events.

Package info

github.com/jonaaix/laravel-audit-trails

pkg:composer/aaix/laravel-audit-trails

Statistics

Installs: 30

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.1.0 2026-08-27 20:50 UTC

This package is auto-updated.

Last update: 2026-08-27 20:52:07 UTC


README

Laravel Audit Trails Logo

Laravel Audit Trails

A lightweight Laravel audit-log package — one trait, polymorphic by design, soft-delete aware.

Latest Version on Packagist Total Downloads GitHub Actions License

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.