定制 mahedulhasan/audit-logger 二次开发

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

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

mahedulhasan/audit-logger

最新稳定版本:v1.0.0

Composer 安装命令:

composer require mahedulhasan/audit-logger

包简介

Laravel Audit Logging Package

README 文档

README

A simple Laravel Audit Logging Package to track database changes on your models. Tracks create, update, delete events and stores only the changed fields in audit_logs table.

Features

  • Logs created, updated, and deleted events automatically
  • Only stores changed fields (old_values & new_values) on updates
  • Tracks which user made the changes
  • Stores client IP address
  • Dynamic observer attachment for all or selected models
  • Bootstrap-based view to display audit logs
  • Easy to integrate as a Laravel package

Requirements

  • Laravel 9 / 10
  • PHP >= 8.1
  • MySQL or any database supported by Laravel

Installation

Require the package via Composer:

composer require mahedulhasan/audit-logger

Make sure your minimum-stability in composer.json allows dev packages if needed:

"minimum-stability": "dev",
"prefer-stable": true

Run the migrations:

php artisan migrate

(Optional) Publish views/config if you want to customize:

php artisan vendor:publish --provider="MahedulHasan\AuditLogger\AuditLoggerServiceProvider"

Development Version (GitHub)

If you want to use the latest development version, install directly from GitHub:

  1. Add the VCS repository to your project's composer.json:
"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/ripuhasan/audit-logger"
    }
]
  1. Require the dev-main branch:
composer require mahedulhasan/audit-logger:dev-main

Usage

Observer

The package automatically attaches AuditObserver to your models. To attach manually:

use App\Models\User;
use MahedulHasan\AuditLogger\Observers\AuditObserver;

User::observe(AuditObserver::class);

Display Audit Logs

Visit the route:

/audit-logs

This route displays a Bootstrap table showing:

  • User
  • Event (Created / Updated / Deleted)
  • Model & ID
  • Changed fields (old → new)
  • IP Address
  • Timestamp

Note: The route is automatically registered by the package's ServiceProvider.

Development

  • Add new migrations in database/migrations/
  • Add additional observers in src/Observers/
  • Update views in resources/views/
  • Run composer dump-autoload if you add new namespaces

Notes

  • No local installation needed. The package can be installed directly via Composer.
  • Ensure ServiceProvider is registered automatically via extra.laravel.providers in composer.json.
  • Migrations, routes, and views are loaded automatically. You only need to run php artisan migrate.

License

MIT License © [Mahedul Hasan]

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-10-23