PHP Classes

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

Recommend this page to a friend!
  Info   View files Documentation   View files View files (14)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 15 All time: 10,470 This week: 38Up
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: 14 packages by
Country: Latvia Latvia
Age: 52
All time rank: 22117 in Latvia Latvia
Week rank: 89 Up2 in Latvia Latvia Up
Innovation award
Innovation award
Nominee: 9x

Winner: 2x

Details

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  
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  /  actions  
File Role Description
  Plain text file AudittrailListAction.php Class Class source

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

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

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

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

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

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

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

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

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

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

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

 Version Control Unique User Downloads Download Rankings  
 100%
Total:15
This week:0
All time:10,470
This week:38Up
For more information send a message to info at phpclasses dot org.