2017 © Pedro Peláez
 

yii2-extension yii2-audittrail

Yii2-audittrail tracks changes to a model with behavior implementation, based on package asinfotrack/yii2-audittrail by Pascal Mueller, AS infotrack AG

image

dpodium/yii2-audittrail

Yii2-audittrail tracks changes to a model with behavior implementation, based on package asinfotrack/yii2-audittrail by Pascal Mueller, AS infotrack AG

  • Monday, March 6, 2017
  • by dpodium
  • Repository
  • 3 Watchers
  • 0 Stars
  • 115 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 2 % Grown

The README.md

Yii2-audittrail

Yii2-audittrail tracks changes to a model with behavior implementation., (*1)

Based on package asinfotrack/yii2-audittrail by Pascal Mueller, AS infotrack AG., (*2)

Installation

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

Either run, (*4)

$ composer require dpodium/yii2-audittrail

or add, (*5)

"dpodium/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/dpodium/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 [
        // ...
        'yii2-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'],
]) ?>

The Versions

06/03 2017

dev-master

9999999-dev

Yii2-audittrail tracks changes to a model with behavior implementation, based on package asinfotrack/yii2-audittrail by Pascal Mueller, AS infotrack AG

  Sources   Download

MIT

The Requires

 

yii2 bundle widget behavior audit history trail audittrail