PHP code example of dataworkstr / revisionable

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

    

dataworkstr / revisionable example snippets


    'providers' => array(

        ...

        'Sofa\Revisionable\Laravel\ServiceProvider',
    ),



return [

    /*
    |--------------------------------------------------------------------------
    | User provider (auth) implementation.
    |--------------------------------------------------------------------------
    |
    | By default Laravel generic Illuminate\Auth\Guard.
    |
    | Supported options:
    |  - illuminate
    |  - sentry
    |  - sentinel
    |  - jwt-auth
    */
    'userprovider' => 'illuminate',


    /*
    |--------------------------------------------------------------------------
    | User field to be saved as the author of tracked action.
    |--------------------------------------------------------------------------
    |
    | By default:
    |
    |  - id for illuminate
    |  - login field (email) for sentry/sentinel
    |  - id or ANY field in User model for tymon/jwt-auth
    */
    'userfield'    => null,


    /*
    |--------------------------------------------------------------------------
    | Table used for the revisions.
    |--------------------------------------------------------------------------
    */
    'table'        => 'revisions',
    
         /*
     |--------------------------------------------------------------------------
     | Table max revision count / default=10
     |--------------------------------------------------------------------------
     */
      'options'        => [
          'max_revision'=>10
      ],   

];

 namespace App;

use Sofa\Revisionable\Laravel\RevisionableTrait; // trait
use Sofa\Revisionable\Revisionable; // interface

class User extends \Eloquent implements Revisionable {

    use RevisionableTrait;

    /*
     * Set revisionable whitelist - only changes to any
     * of these fields will be tracked during updates.
     */
    protected $revisionable = [
        'email',
        'name',
        'phonenumber.main_phone.0'
    ];

~$ php artisan vendor:publish [--provider="Sofa\Revisionable\Laravel\ServiceProvider"]

~$ php artisan migrate [--database=custom_connection]