定制 laravel-enso/audit 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

laravel-enso/audit

Composer 安装命令:

composer require laravel-enso/audit

包简介

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

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

laravel-enso/audit 适用场景与选型建议

laravel-enso/audit 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 302 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 05 月 11 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「Audit」 「history」 「laravel-enso」 「audit-log」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 laravel-enso/audit 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 laravel-enso/audit 我们能提供哪些服务?
定制开发 / 二次开发

基于 laravel-enso/audit 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-11