Laravel EnsoLaravel Enso
Guide
Back End
Front End
GitHub
Guide
Back End
Front End
GitHub
  • Back End

    • Action Logger
    • Addresses
    • Alfa Sign
    • Algolia
    • Algolia Webshop
    • API
    • Audit
    • Avatars
    • BTRL (Banca Transilvania iPay)
    • Cache Chain
    • Calendar
    • Cargo Partner
    • Categories
    • Charts
    • CI/CD
    • Cli
    • CNP Validator
    • Comments
    • Commercial
    • Companies
    • Core
    • Countries
    • Currencies
    • Data Export
    • Data Import
    • Discounts
    • Documents
    • Dynamic Methods
    • EAV
    • Emag
    • Emag Checker
    • Enums
    • Excel
    • Facebook
    • Files
    • Filters
    • Financials
    • Forms
    • Frisbo
    • Google
    • Helpers
    • Holidays
    • How-to
    • Image Transformer
    • Impersonate
    • Interactions
    • Inventory
    • IO
    • Localisation
    • Lockable Models
    • Logs
    • Mails
    • Measurement Units
    • Meili Search
    • Meili Search Webshop
    • Menus
    • Migrator
    • Monitored Emails
    • Notifications
    • Packaging Units
    • PDF
    • People
    • Permissions
    • Product Eav
    • Product Lots
    • Products
    • Projects
    • Questionnaires
    • Rememberable
    • Roles
    • Sale Channels
    • Searchable
    • Select
    • Send SMS (Sendsms.ro)
    • Sentry
    • Services
    • Smart Bill
    • Sms Advert
    • Stripe
    • Sunrise Sunset
    • System Notifications
    • Tables
    • Tasks
    • Teams
    • Ticketing
    • Track Who
    • Tutorials
    • Typesense
    • Typesense Webshop
    • Unit Conversion
    • Upgrade
    • UPS
    • User Groups
    • Users
    • Versions
    • Virtual Call Center
    • Vouchers
    • Webshop
    • Webshop Commercial

Audit

LicenseStableDownloadsPHPIssuesMerge Requests

Description

Audit records Eloquent model create, update, and delete events and exposes them through an Enso table endpoint.

The package does not auto-discover auditable models. Each application or package must explicitly list the models it wants audited in its audit service provider. The package registers the audit observer for those models.

Installation

Install the package:

composer require laravel-enso/audit

Run the package migrations:

php artisan migrate

Features

  • Stores created, updated, and deleted events together with before/after payloads.
  • Uses explicit model registration through AuditServiceProvider::$models.
  • Supports restricted payloads through an auditableAttributes() method on the audited model.
  • Registers the audit observer for configured models and exposes those classes as select options for the frontend model filter.
  • Exposes the audit creation timestamp as a sortable date column for table and date interval filtering.
  • Stores the actor through track-who on the audit record itself.
  • Publishes table-init, table-data, export, and model-options endpoints under api/system/audit.

Usage

Register auditable models from the consuming application or package service provider:

namespace App\Providers;

use App\Models\Invoice;
use LaravelEnso\Audit\AuditServiceProvider as ServiceProvider;

class AuditServiceProvider extends ServiceProvider
{
    public $models = [
        Invoice::class,
    ];
}

By default, all model attributes are recorded.

To limit the recorded payload, define an auditableAttributes() method on the model:

use Illuminate\Database\Eloquent\Model;

class Invoice extends Model
{
    public function auditableAttributes(): array
    {
        return ['status', 'total'];
    }
}

Upgrade Guide

2.0.7

Audit providers now declare audited models through public $models = [...]. The package registers LaravelEnso\Audit\Observers\Audit automatically for that list and exposes the same model list to the frontend filter endpoint. Replace older $auditable or $observers declarations with $models.

2.0.3

The audit table now includes the created_at date column, enabling the frontend date interval filter on audit rows.

2.0.2

Audited model classes are now collected from AuditServiceProvider::$models, registered with the audit observer, and exposed through system.audit.models / GET api/system/audit/models for frontend model filters.

2.0.0

This is a breaking release.

Auditable model discovery was removed. Models are no longer detected automatically. List each audited model in AuditServiceProvider::$models; the package registers LaravelEnso\Audit\Observers\Audit for that list. To restrict the recorded payload, define an auditableAttributes() method on that model.

API

Main route group

Mounted under api/system/audit:

  • system.audit.initTable
  • system.audit.tableData
  • system.audit.exportExcel
  • system.audit.models

The model options route returns the audited models registered through AuditServiceProvider::$models:

  • GET api/system/audit/models

Core classes

  • LaravelEnso\Audit\AuditServiceProvider
  • LaravelEnso\Audit\Observers\Audit
  • LaravelEnso\Audit\Models\Audit
  • LaravelEnso\Audit\Services\Models

Depends On

Required Enso packages:

  • laravel-enso/enums
  • laravel-enso/migrator
  • laravel-enso/select
  • laravel-enso/tables
  • laravel-enso/track-who
  • laravel-enso/users

Companion frontend package:

  • @enso-ui/audit ↗

Contributions

are welcome. Pull requests are great, but issues are good too.

Thank you to all the people who already contributed to Enso!

License

MIT

Edit this page on GitHub
Last Updated: 5/13/2026, 10:31:47 AM
Prev
API
Next
Avatars