PHP code example of igor-tv / oc-revisionable-behavior

1. Go to this page and download the library: Download igor-tv/oc-revisionable-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/ */

    

igor-tv / oc-revisionable-behavior example snippets


\RainLab\User\Models\User::extend(function ($model) {
    $model->implement[] = 'Iweb.Behaviors.RevisionableModel';

    $revisionableFields = [
        'name',
        'email'
    ];
    
    //rename revisions model relation
    $model->addDynamicProperty('revisionHistoryRelationName', 'your_history_relation_name');
    
    //optional, if you need assosiate changes with backend users
    $model->addDynamicMethod('getRevisionableUser', function () {
        if (!\BackendAuth::check()) {
            return null;
        }
  
        return \BackendAuth::getUser()->id;
    });
});