Audits
Description
Audits records model create, update, and delete events across monitored Eloquent models and exposes them through an Enso table endpoint.
The package auto-registers a model observer for all auditable models discovered under the configured vendor roots, stores before/after change payloads in the audits table, and publishes the backend routes consumed by the matching frontend audits page.
Installation
Install the package:
composer require laravel-enso/audits
Run the package migrations:
php artisan migrate
The package auto-discovers its service providers. In applications that need to narrow the monitored model set, extend LaravelEnso\\Audits\\AuditServiceProvider in the host app and register the custom provider in bootstrap/providers.php.
Features
- Automatically observes auditable models discovered under the configured vendor directories.
- Stores
created,updated, anddeletedevents together with before/after payloads. - Supports restricted auditing through the
RestrictedAuditablecontract. - Publishes table-init, table-data, export, and options endpoints under
api/system/audit.
Usage
Mark a model as auditable:
use Illuminate\Database\Eloquent\Model;
use LaravelEnso\Audits\Contracts\Auditable;
class Invoice extends Model implements Auditable
{
}
Limit the recorded attributes:
use Illuminate\Database\Eloquent\Model;
use LaravelEnso\Audits\Contracts\RestrictedAuditable;
class Invoice extends Model implements RestrictedAuditable
{
public function auditableAttributes(): array
{
return ['status', 'total'];
}
}
By default, the package scans all vendor folders listed in config('enso.audits.vendors') and the application namespace for models that implement the auditing contracts.
API
Main route group
Mounted under api/system/audit:
system.audit.initTablesystem.audit.tableDatasystem.audit.exportExcelsystem.audit.options
Contracts
LaravelEnso\\Audits\\Contracts\\AuditableLaravelEnso\\Audits\\Contracts\\RestrictedAuditable
Core classes
LaravelEnso\\Audits\\Observers\\ModelObserverLaravelEnso\\Audits\\Models\\AuditLaravelEnso\\Audits\\Services\\AuditableModels
Depends On
Required Enso packages:
Companion frontend package:
Contributions
are welcome. Pull requests are great, but issues are good too.
Thank you to all the people who already contributed to Enso!