PHP code example of neoacevedo / yii2-auditing

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/ */

    

neoacevedo / yii2-auditing example snippets


...
'@vendor/neoacevedo/yii2-auditing/neoacevedo/auditing/migrations',
...

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),
        ]);
    }

...
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
            'id',
            'user_id',
            'description',
            'event',
            'model',
            'attribute',
            'old_value',
            'new_value',
            'action',
            'ip',
            'created_at',
        ],
    ]); 

php composer.phar