laravel-enso/audits 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

laravel-enso/audits

最新稳定版本:2.0.5

Composer 安装命令:

composer require laravel-enso/audits

包简介

Model auditing endpoints and change-history storage for Laravel Enso

README 文档

README

License Stable Downloads PHP Issues Merge 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 attach LaravelEnso\Audit\Observers\Audit to the models it wants audited.

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 observer registration per model.
  • Supports restricted payloads through an auditableAttributes() method on the audited model.
  • Collects observed model classes and exposes them 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 the observer from the consuming application or package service provider:

namespace App\Providers;

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

class AuditServiceProvider extends ServiceProvider
{
    public $observers = [
        Invoice::class => [Audit::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.3

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

2.0.2

Observed model classes are now collected from AuditServiceProvider::$observers 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, and the package no longer registers observers on its own.

Attach LaravelEnso\Audit\Observers\Audit manually on each model that should be audited. 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 the audit service provider:

  • 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:

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!

License

MIT

统计信息

  • 总下载量: 178
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固