dpodium/yii2-audittrail
Composer 安装命令:
composer require 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
README 文档
README
Yii2-audittrail tracks changes to a model with behavior implementation.
Based on package asinfotrack/yii2-audittrail by Pascal Mueller, AS infotrack AG.
Installation
The preferred way to install this extension is through composer.
Either run
$ composer require dpodium/yii2-audittrail
or add
"dpodium/yii2-audittrail": "dev-master"
to the require section of your composer.json file.
Migration
After downloading everything you need to apply the migration creating the audit trail entry table:
yii migrate --migrationPath=@vendor/dpodium/yii2-audittrail/migrations
To remove the table just do the same migration downwards.
Usage
Behavior
Attach the behavior to your model and you're done:
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:
<?= 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'], ]) ?>
统计信息
- 总下载量: 207
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-06-23