Skip to content

Installation

Requirements

  • PHP 8.3+
  • Laravel 13.0+

Install via Composer

bash
composer require aaix/laravel-audit-trails

The service provider is auto-discovered, so no manual registration is needed.

Publish the migration

bash
php artisan vendor:publish --tag="audit-trails-migrations"
php artisan migrate

This creates the audit_trails table:

ColumnTypeNotes
idbigIncrementsPrimary key
actionstringOne of created/updated/deleted/restored/force_deleted
auditable_typestringPolymorphic — model class
auditable_idunsignedBigIntegerPolymorphic — model PK
user_idunsignedBigInteger, nullResolved by user_resolver config
changes_jsonjson, nullgetChanges() payload for updated
created_attimestamp
updated_attimestamp

A composite index on (auditable_type, auditable_id) is created via morphs().

Publish the config (optional)

bash
php artisan vendor:publish --tag="audit-trails-config"

The published file lives at config/audit-trails.php — see Configuration.

Released under the MIT License.