add history of changes to all entitys
This commit is contained in:
@ -91,9 +91,17 @@ class NotesController extends Controller
|
||||
],
|
||||
]);
|
||||
|
||||
$changeDataProvider = new ActiveDataProvider([
|
||||
'query' => \common\models\ChangeHistory::find()->where(['type_id' => $this->findModel($id)->id]),
|
||||
'pagination' => [
|
||||
'pageSize' => 200,
|
||||
]
|
||||
]);
|
||||
|
||||
return $this->render('view', [
|
||||
'model' => Note::findOne($id),
|
||||
'additionalDataProvider' => $additionalDataProvider
|
||||
'additionalDataProvider' => $additionalDataProvider,
|
||||
'changeDataProvider' => $changeDataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,15 @@ class Note extends \common\models\Note
|
||||
}
|
||||
}
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'log' => [
|
||||
'class' => \common\behaviors\LogBehavior::class,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function afterSave($insert, $changedAttributes)
|
||||
{
|
||||
$post = \Yii::$app->request->post('Note');
|
||||
|
@ -52,4 +52,16 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
],
|
||||
]); ?>
|
||||
|
||||
<h2>История изменений</h2>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $changeDataProvider,
|
||||
'columns' => [
|
||||
'label',
|
||||
'old_value',
|
||||
'new_value',
|
||||
'created_at',
|
||||
],
|
||||
]); ?>
|
||||
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user