add history of changes to all entitys

This commit is contained in:
vladrigos
2020-08-06 13:19:20 +03:00
parent 812bb2b23a
commit 6aff5567c4
16 changed files with 174 additions and 19 deletions

View File

@ -38,6 +38,9 @@ class CompanyController extends Controller
],
],
],
'log' => [
'class' => \common\behaviors\LogBehavior::class,
]
];
}
@ -72,9 +75,18 @@ class CompanyController extends Controller
'pageSize' => 200,
],
]);
$changeDataProvider = new ActiveDataProvider([
'query' => \common\models\ChangeHistory::find()->where(['type_id' => $this->findModel($id)->id]),
'pagination' => [
'pageSize' => 200,
]
]);
return $this->render('view', [
'model' => $this->findModel($id),
'dataProviderF' => $dataProviderF
'dataProviderF' => $dataProviderF,
'changeDataProvider' => $changeDataProvider,
]);
}

View File

@ -43,6 +43,15 @@ class Company extends \common\models\Company
}
}
public function behaviors()
{
return [
'log' => [
'class' => \common\behaviors\LogBehavior::class,
]
];
}
public function afterSave($insert, $changedAttributes)
{
$post = \Yii::$app->request->post('Company');

View File

@ -50,4 +50,16 @@ $this->params['breadcrumbs'][] = $this->title;
],
]); ?>
<h2>История изменений</h2>
<?= GridView::widget([
'dataProvider' => $changeDataProvider,
'columns' => [
'label',
'old_value',
'new_value',
'created_at',
],
]); ?>
</div>