PHP code example of asc / revisionable

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

    

asc / revisionable example snippets


"venturecraft/revisionable": "1.*",

namespace MyApp\Models;

class Article extends Eloquent {
    use \Venturecraft\Revisionable\RevisionableTrait;
}

use Venturecraft\Revisionable\Revisionable;

namespace MyApp\Models;

class Article extends Revisionable { }

namespace MyApp\Models;

class Article extends Eloquent {
    use Venturecraft\Revisionable\RevisionableTrait;

    protected $revisionEnabled = false;
}

protected $keepRevisionOf = array(
    'title'
);

protected $dontKeepRevisionOf = array(
    'category_id'
);

protected $revisionFormattedFields = array(
    'title'  => 'string:<strong>%s</strong>',
    'public' => 'boolean:No|Yes',
    'deleted_at' => 'isEmpty:Active|Deleted'
);

protected $revisionFormattedFieldNames = array(
    'title' => 'Title',
    'small_name' => 'Nickname',
    'deleted_at' => 'Deleted At'
);

$article = Article::find($id);
$history = $article->revisionHistory;

@foreach($account->revisionHistory as $history )
    <li>{{ $history->userResponsible()->first_name }} changed {{ $history->fieldName() }} from {{ $history->oldValue() }} to {{ $history->newValue() }}</li>
@endforeach

use Venturecraft\Revisionable\Revisionable;

class Article extends Revisionable
{
    public function identifiableName()
    {
        return $this->title;
    }
}

protected $revisionNullString = 'nothing';
protected $revisionUnknownString = 'unknown';

$object->disableRevisionField('title'); // Disables title

$object->disableRevisionField(array('title', 'content')); // Disables title and content

php composer.phar update

php artisan migrate --package=venturecraft/revisionable