PHP Classes

D3 PHP Record Audit Trail: Keep track of changes to model object data values

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 17 All time: 11,339 This week: 455Up
Version License PHP version Categories
d3audittrail 1.0Freeware5PHP 5, Databases, Libraries, Design P...
Description 

Author

This package can be used to keep track of changes to model object data values.

It can add a behavior to model classes that use the YII framework, so it can create a trail of changes done to the values of to objects of those model classes by recording in a separate table the list of changes done on those model objects.

The model classes need to implement a few functions that define which values of the model objects are recorded or not in the audit trail table.

Picture of Uldis Nelsons
Name: Uldis Nelsons <contact>
Classes: 19 packages by
Country: Latvia Latvia
Age: 55
All time rank: 19476 in Latvia Latvia
Week rank: 195 Up2 in Latvia Latvia Up
Innovation award
Innovation award
Nominee: 12x

Winner: 2x

Documentation

Total Downloads

Display audittrail data

Add migrations paths

    'controllerMap' => [
        'migrate' => [
            'class' => 'yii\console\controllers\MigrateController',
            'migrationPath' => [
                '@vendor/sammaye/yii2-audittrail/migrations',
                '@vendor/d3yii2/d3audittrail/migrations',

            ],
        ],
    ],

Define module in console and web

    'modules' => [

        'd3audittrail' => [
            'class' => 'd3yii2\d3audittrail\Module',
        ],
    ]    

define in parameters table name

    'params' => [
        'audittrail.table' => 'tbl_audit_trail'
    ]    

Add to model behaviors


    public function behaviors(): array
    {
        return ArrayHelper::merge(
            parent::behaviors(),
            [
                'sammaye\audittrail\LoggableBehavior'
            ]
        );
    }

Define model label

class Model extends extends \yii\db\ActiveRecord
    /
    * model label 
    */
    public function tableLabel(): string
    {
        return 'Data Record';
    }

    public static function audittrailHiddedFields()
    {
        return [
            'password'
        ];
    }

    public static function audittrailSqlFields()
    {
        return [
            'client_id' => 'select name from client where id=:id'
        ];
    }

    public static function audittrailRefModels()
    {
        return [
            [
                'model' => TblAuditTrail::class,
                'ref_field' => 'my_id',
                'hidded_fields' => ['a','b'],
                'field_sql' => [
                    'field1' => 'select name from user where id=:id'
                 ]               
            ]           
        ];
    }
}

Add to view button

    $this->addPageButtons(AuditTrailButton::widget([
                'modelName' => coalmar\delivery\models\CmdDelivery::className(),
                'modelId' => $model->id
    ]));

  Files folder image Files (14)  
File Role Description
Files folder imageactions (1 file)
Files folder imagecontrollers (1 file)
Files folder imagegii (1 file)
Files folder imagemessages (1 directory)
Files folder imagemigrations (1 file)
Files folder imagemodels (1 file, 1 directory)
Files folder imagetraits (1 file)
Files folder imageviews (1 directory)
Files folder imagewidgets (2 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Plain text file Module.php Class Class source
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (14)  /  actions  
File Role Description
  Plain text file AudittrailListAction.php Class Class source

  Files folder image Files (14)  /  controllers  
File Role Description
  Plain text file DataController.php Class Class source

  Files folder image Files (14)  /  gii  
File Role Description
  Accessible without login Plain text file tbl_audit_trailGiiantModel.json Data Auxiliary data

  Files folder image Files (14)  /  messages  
File Role Description
Files folder imagelv (1 file)

  Files folder image Files (14)  /  messages  /  lv  
File Role Description
  Accessible without login Plain text file d3audittrail.php Aux. Auxiliary script

  Files folder image Files (14)  /  migrations  
File Role Description
  Plain text file m171106_184558_utf...r_value_columns.php Class Class source

  Files folder image Files (14)  /  models  
File Role Description
Files folder imagebase (1 file)
  Plain text file TblAuditTrail.php Class Class source

  Files folder image Files (14)  /  models  /  base  
File Role Description
  Plain text file TblAuditTrail.php Class Class source

  Files folder image Files (14)  /  traits  
File Role Description
  Plain text file ActiveRecordDbConnectionTrait.php Class Class source

  Files folder image Files (14)  /  views  
File Role Description
Files folder imagedata (1 file)

  Files folder image Files (14)  /  views  /  data  
File Role Description
  Accessible without login Plain text file list.php Example Example script

  Files folder image Files (14)  /  widgets  
File Role Description
  Plain text file AuditTrailActionButton.php Class Class source
  Plain text file AuditTrailButton.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:17
This week:0
All time:11,339
This week:455Up