承接 bhhaskin/laravel-audit 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

bhhaskin/laravel-audit

最新稳定版本:0.1.0

Composer 安装命令:

composer require bhhaskin/laravel-audit

包简介

Audit trail package for Laravel applications with UUID support.

README 文档

README

Lightweight audit trail package for Laravel applications.

Features

  • Records created, updated, deleted, and restored events for any model.
  • Stores both numeric primary keys and UUIDs for audits, auditable models, and users.
  • Captures before/after state, request metadata, and user attribution.
  • Ships with ready-to-run migrations plus publishable stubs and configuration.

Installation

composer require bhhaskin/laravel-audit

Laravel auto-discovers the service provider. For older versions add LaravelAudit\AuditServiceProvider::class to the providers array in config/app.php.

Publish Assets

php artisan vendor:publish --provider="LaravelAudit\AuditServiceProvider" --tag=laravel-audit-config
php artisan vendor:publish --provider="LaravelAudit\AuditServiceProvider" --tag=laravel-audit-migrations

Run the migration:

php artisan migrate

Usage

  1. Add the Auditable trait to any Eloquent model that you want to track.
  2. Ensure the model has a uuid column populated via the included HasAuditUuid trait or your own logic.
use Illuminate\Database\Eloquent\Model;
use LaravelAudit\Traits\Auditable;
use LaravelAudit\Traits\HasAuditUuid;

class Post extends Model
{
    use HasAuditUuid;
    use Auditable;
}

Audits are exposed through the audits() relationship:

$post = Post::first();

foreach ($post->audits as $audit) {
    echo $audit->uuid; // Frontend-friendly identifier
}

Configuration

Published configuration (config/audit.php) lets you:

  • Enable/disable the logger or specific events.
  • Ignore fields such as timestamps when diffing changes.
  • Add default metadata and provide a custom user resolver.

The default user resolver defers to Laravel's auth() helper. Implement a custom resolver by binding a callable class and updating user_resolver in the config.

Events

Two framework events are fired for each audit lifecycle:

  • LaravelAudit\Events\AuditRecording (before persistence) exposes the proposed payload for last-minute tweaks.
  • LaravelAudit\Events\AuditRecorded (after persistence) includes the saved Audit model instance.

Listen for these events to trigger notifications, broadcast changes, or enrich metadata.

License

MIT © Bryan

Testing

composer install
composer test

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固