2017 © Pedro Peláez
 

package laravel-audit-trail

Keep a change history for your models using laravel version 5.1.*

image

unisharp/laravel-audit-trail

Keep a change history for your models using laravel version 5.1.*

  • Monday, March 26, 2018
  • by g0110280
  • Repository
  • 6 Watchers
  • 4 Stars
  • 470 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 7 % Grown

The README.md

Laravel Audit Trail

What is this package for?

  • This package is for laravel 5.0/5.1, which helps you create your auditing logs into your database.

Setup

  1. In /config/app.php, add the following to providers:, (*1)

    Unisharp\AuditTrail\AuditServiceProvider::class,
    

    and the following to aliases:, (*2)

    'Audit' => Unisharp\AuditTrail\Facades\Audit::class,
    
  2. Run php artisan vendor:publish.
  3. Run php artisan migrate.

Usage

All your logs will be recorded in 'audit_trails' table., (*3)

  • You need to add a trait to the model you're going to audit., (*4)

    class User extends Eloquent
    {
      use \Unisharp\AuditTrail\Auditable;
    
      protected $table = 'users';
    
      protected $hidden = ['password'];
    
      protected $fillable = ['username', 'email', 'password'];
    }
    
  • In any place you want to audit your user logs, (*5)

    $User->log($action, $comment = null, $subject = null, $subject_id = null)
    
    Audit::log($action, $comment = null)
    
    $User->log('log in', 'the action is approved')
    
    Audit::log('log in', 'the action is approved')
    
    • $User is an Eloquent Object here.
    • The second, third parameters are optional.
    • You could put your modified column and column id to subject and subject_id parameters.
  • Other usages, (*6)

    • You can get your model logs by:, (*7)

      $User->getLogs();
      
    • Get all the logs by single user by using:, (*8)

      Audit::getByUserId($user_id)
      
    • As time grows, logs would be outdated. You may clean them by:, (*9)

      $User->cleanLogs()
      

License

This package is licensed under MIT license., (*10)

The Versions

26/03 2018

dev-master

9999999-dev

Keep a change history for your models using laravel version 5.1.*

  Sources   Download

MIT

The Requires

 

laravel log auditing

06/11 2015

dev-feature-trait

dev-feature-trait

Keep a change history for your models using laravel version 5.1.*

  Sources   Download

MIT

The Requires

 

laravel log auditing

05/11 2015

dev-feature-model

dev-feature-model

Keep a change history for your models using laravel version 5.1.*

  Sources   Download

MIT

The Requires

 

laravel log auditing