1. Go to this page and download the library: Download neoacevedo/yii2-auditing 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/ */
public function behaviors()
{
return [
[
'class' => \neoacevedo\auditing\behaviors\AuditBehavior::class,
'deleteOldData' => true, // Para borrar datos antiguos del registro de eventos
'deleteNumRows' => 20, // Borra esta cantidad de registros
'ignored' => ['foo', 'bar'], // No registra en el registro de eventos estos atributos del modelo
],
...
];
}
/**
* Lists all Auditing models.
*
* @return string
*/
public function actionIndex()
{
$searchModel = new AuditingSearch();
$dataProvider = $searchModel->search($this->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single Auditing model.
* @param int $id ID
* @return string
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}