tectiv3 / loggable
:本包允许Laravel模型具有自动日志记录功能
dev-master
2019-02-07 02:49 UTC
Requires
- php: >=5.4.0
- illuminate/database: ~5.2
- illuminate/support: ~5.2
This package is auto-updated.
Last update: 2024-09-07 15:38:25 UTC
README
Loggable是一个Laravel 5包,帮助用户简单记录模型CRUD操作日志。
安装
$ composer require tectiv3/loggable
- 将服务提供者添加到app.php中的providers数组
tectiv3\Loggable\ServiceProvider::class //Then do vendor:publish from the artisan command to copy the migration file and run migrate command php artisan vendor:publish --provider="tectiv3\Loggable\ServiceProvider" php artisan migrate
用法
//use Loggable in any of your models whose CRUD logs you want to keep use tectiv3\Loggable\Loggable; class DemoModel extends \Eloquent { use Loggable; } //for all logs loop through \tectiv3\Loggable\Log::all() or filter it however you like //for model specific logs you can call $model->logs to get model specific logs //then inside the loop you can access the user with ->user property foreach($model->logs as $log){ echo $log->entity . ' || ' . $log->action; echo '<br>'; echo 'By :'.$log->user->name.' at '.$log->created_at; }
致谢
许可证
MIT许可证(MIT)。请参阅许可证文件获取更多信息。