PHP code example of shamanzpua / entity-change-log-behavior

1. Go to this page and download the library: Download shamanzpua/entity-change-log-behavior 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/ */

    

shamanzpua / entity-change-log-behavior example snippets


 public function behaviors()
  {
      return [
          [
              'class' => EntityChangeLogBehavior::class,

              'logModelClass' => Log::class,  //ActiveRecord log table class

              'attributes' => [   //attributes of owner. Default: all attributes
                  'name',
                  'date',
                  'id',
              ],

              'columns' => [  //Required log table columns
                  'action' => 'action_column_name' // Default 'action',
                  'new_value' => 'new_value_column_name' // Default 'new_value',
                  'old_value' => 'old_value_column_name' // Default 'old_value',
              ],

              'relatedAttributes' => [   //attributes of owners relations
                  'user' => ['email'],
                  'category' => ['name'],
              ],

              'additionalLogTableFields' => [   //additional log table fields. key -> log table col, value -> owners col
                  'log_item_name' => 'title',
              ],
          ]
      ];
  }