2017 © Pedro Peláez
 

yii2-extension yii2-audittrail

Yii2-audittrail is a behavior and a set of widgets to track all modifications performed on a model

image

asinfotrack/yii2-audittrail

Yii2-audittrail is a behavior and a set of widgets to track all modifications performed on a model

  • Tuesday, February 27, 2018
  • by asinfotrack
  • Repository
  • 9 Watchers
  • 10 Stars
  • 2,354 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 10 Forks
  • 2 Open issues
  • 5 Versions
  • 12 % Grown

The README.md

Yii2-audittrail

Yii2-audittrail is a behavior and a set of widgets to track all modifications performed on a model, (*1)

Advantages

This is not the first audit trail extension. So why use this one? Those are some of the major advantages:, (*2)

  • this extension works with composite primary keys
  • it also works with console applications
  • you can explicitly configure what fields to log
  • GridView-baded widget to show the audit trail with huge customization options (eg rendering of values by closures, yii-formatter, etc.)

Installation

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

$ composer require asinfotrack/yii2-audittrail

or add, (*5)

"asinfotrack/yii2-audittrail": "dev-master"

to the require section of your composer.json file., (*6)

Migration

After downloading everything you need to apply the migration creating the audit trail entry table:, (*7)

yii migrate --migrationPath=@vendor/asinfotrack/yii2-audittrail/migrations

To remove the table just do the same migration downwards., (*8)

Usage

Behavior

Attach the behavior to your model and you're done:, (*9)

public function behaviors()
{
    return [
        // ...
        'audittrail'=>[
            'class'=>AuditTrailBehavior::className(),

            // some of the optional configurations
            'ignoredAttributes'=>['created_at','updated_at'],
            'consoleUserId'=>1, 
            'attributeOutput'=>[
                'desktop_id'=>function ($value) {
                    $model = Desktop::findOne($value);
                    return sprintf('%s %s', $model->manufacturer, $model->device_name);
                },
                'last_checked'=>'datetime',
            ],
        ],
        // ...
    ];
}

Widget

The widget is also very easy to use. Just provide the model to get the audit trail for:, (*10)

<?= AuditTrail::widget([
    'model'=>$model,

    // some of the optional configurations
    'userIdCallback'=>function ($userId, $model) {
        return User::findOne($userId)->fullname;
    },
    'changeTypeCallback'=>function ($type, $model) {
        return Html::tag('span', strtoupper($type), ['class'=>'label label-info']);
    },
    'dataTableOptions'=>['class'=>'table table-condensed table-bordered'],
]) ?>

Changelog

Learn about the latest improvements., (*11)

The Versions

27/02 2018

dev-master

9999999-dev

Yii2-audittrail is a behavior and a set of widgets to track all modifications performed on a model

  Sources   Download

MIT

The Requires

 

yii2 bundle widget behavior audit history trail audittrail

31/10 2017

0.8.3

0.8.3.0

Yii2-audittrail is a behavior and a set of widgets to track all modifications performed on a model

  Sources   Download

MIT

The Requires

 

yii2 bundle widget behavior audit history trail audittrail

16/03 2016

0.8.2

0.8.2.0

Yii2-audittrail is a behavior and a set of widgets to track all modifications performed on a model

  Sources   Download

MIT

The Requires

 

yii2 bundle widget behavior audit history trail audittrail

22/02 2016

0.8.1

0.8.1.0

Yii2-audittrail is a behavior and a set of widgets to track all modifications performed on a model

  Sources   Download

MIT

The Requires

 

yii2 bundle widget behavior audit history trail audittrail

26/01 2016

0.8.0

0.8.0.0

Yii2-audittrail is a behavior and a set of widgets to track all modifications performed on a model

  Sources   Download

MIT

The Requires

 

yii2 bundle widget behavior audit history trail audittrail