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

    • Action Logger
    • Addresses
    • Algolia
    • Algolia Webshop
    • API
    • Audits
    • Avatars
    • 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
    • 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
    • Sentry
    • Services
    • Smart Bill
    • Sms Advert
    • Stripe
    • Sunrise Sunset
    • 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

Audits

LicenseStableDownloadsPHPIssuesMerge Requests

Description

Audits 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 attach LaravelEnso\Audits\Observers\ModelObserver to the models it wants audited.

Installation

Install the package:

composer require laravel-enso/audits

Run the package migrations:

php artisan migrate

Features

  • Stores created, updated, and deleted events together with before/after payloads.
  • Uses explicit observer registration per model.
  • Supports restricted payloads through an auditableAttributes() method or $auditableAttributes model property.
  • Publishes table-init, table-data, export, and options endpoints under api/system/audit.

Usage

Register the observer from the consuming application or package service provider:

namespace App\Providers;

use App\Models\Invoice;
use Illuminate\Support\ServiceProvider;
use LaravelEnso\Audits\Observers\ModelObserver;

class AppServiceProvider extends ServiceProvider
{
    public function boot(): void
    {
        Invoice::observe(ModelObserver::class);
    }
}

By default, all model attributes are recorded.

To limit the recorded payload, define either an auditableAttributes() method or an $auditableAttributes property on the model:

use Illuminate\Database\Eloquent\Model;

class Invoice extends Model
{
    public array $auditableAttributes = ['status', 'total'];
}

or:

use Illuminate\Database\Eloquent\Model;

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

Upgrade Guide

2.0.0

This is a breaking release.

Auditable model discovery was removed. Models are no longer detected through Auditable or RestrictedAuditable contracts, and the package no longer registers observers automatically.

Attach LaravelEnso\Audits\Observers\ModelObserver manually on each model that should be audited. To restrict the recorded payload, define an auditableAttributes() method or a public $auditableAttributes property on that model.

API

Main route group

Mounted under api/system/audit:

  • system.audit.initTable
  • system.audit.tableData
  • system.audit.exportExcel
  • system.audit.options

Core classes

  • LaravelEnso\Audits\Observers\ModelObserver
  • LaravelEnso\Audits\Models\Audit

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/audits ↗

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: 4/29/2026, 1:42:18 PM
Prev
API
Next
Avatars