drewlabs/changelog-eloquent
最新稳定版本:v0.3.1
Composer 安装命令:
composer require drewlabs/changelog-eloquent
包简介
eloquent driver for drewlabs/changelog library
README 文档
README
Provides laravel eloquent compatible table changes logger. For more information about changelog implementation, go to [https://packagist.org/packages/drewlabs/changelog].
Usage
To register eloquent changelog driver, simply add the provided service provider in your laravel application configuration:
// config/app.php return [ // ... 'providers' => [ // ... \Drewlabs\Changelog\Eloquent\ServiceProvider::class, // ... ] ]; ``` The library comes with a command for creating logs table in your application database. In order to run the migration: > php artisan changelog:migrate --refresh --connection=<DATABASE_CONNECTION_NAME> **Note** By default, the command use `mysql` connection if no connection option is passed. **Note** The above configuration allows you to easily log table changes in your application. - Loggable trait The library also comes with a handy trait that can be added to your eloquent model that allows them to log their changes using configured drivers. To provide a model with the logging abilities on changes: ```php <?php // ... use Drewlabs\Changelog\Eloquent\Loggable; use Drewlabs\Changelog\Loggable as AbstractLoggable; class MyModel implements AbstractLoggable { use Loggable; // This method is required by the model and should return the table name used when // logging the model changes into storage public function getLogTableName(): string { return sprintf("locations.%s", $this->getTable()); } } ```
统计信息
- 总下载量: 83
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-03-01