项目作者: hasnularief

项目描述 :
Audit or log your laravel model
高级语言: PHP
项目地址: git://github.com/hasnularief/auditor.git
创建时间: 2018-01-07T16:42:15Z
项目社区:https://github.com/hasnularief/auditor

开源协议:MIT License

下载


Auditor for Laravel

Installation

Require this package with composer:

  1. composer require hasnularief/auditor:dev-master

Add packages to autoload and add ServiceProvider to config\app.php

  1. Hasnularief\Auditor\AuditorServiceProvider::class,

Copy the package config to your local config with the publish command:

  1. php artisan vendor:publish --tag=auditor

Auditor will be enabled when AUDITOR is true in .env

How to use

Add AuditorTrait to your model and auditor will audit your model when you write data

  1. use Hasnularief\Auditor\AuditorTrait;
  2. class User extends Model
  3. {
  4. use AuditorTrait;

Auditor using observer to observe your model. If your model already have observer in boot method, you can’t use the first method, but you can include observer directly in model.

  1. use Hasnularief\Auditor\AuditorObserver;
  2. class User extends Model
  3. {
  4. protected static function boot()
  5. {
  6. parent::boot();
  7. $request = request();
  8. static::observe(new AuditorObserver($request));
  9. }

Finally you can access the result in route your-project.dev/auditor

For other configuration you can see in config/auditor.php