1. Go to this page and download the library: Download asinfotrack/yii2-audittrail library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
asinfotrack / yii2-audittrail example snippets
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',
],
],
// ...
];
}
<?= 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'],
])
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.