1. Go to this page and download the library: Download convenia/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/ */
convenia / revisionable example snippets
namespace App;
use Convenia\Revisionable\RevisionableTrait;
class Article extends Eloquent {
use RevisionableTrait;
}
namespace App;
use Convenia\Revisionable\RevisionableTrait;
class Article extends Eloquent {
use RevisionableTrait;
}
namespace App;
use Convenia\Revisionable\RevisionableTrait;
class Article extends Eloquent {
use RevisionableTrait;
protected $revisionEnabled = false;
}
namespace App;
use Convenia\Revisionable\RevisionableTrait;
class Article extends Eloquent {
use RevisionableTrait;
protected $historyLimit = 500; //Stop tracking revisions after 500 changes have been made.
}
namespace App;
use Convenia\Revisionable\RevisionableTrait;
class Article extends Eloquent {
use RevisionableTrait;
protected $revisionCleanup = true; //Remove old revisions (works only when used with $historyLimit)
protected $historyLimit = 500; //Maintain a maximum of 500 changes at any point of time, while cleaning up old revisions.
}
Article::withoutRevision();
$article = Article::create(['title' => 'Amazing Article']);
$article->title = 'New amazing Article';
$article->save();
...
Article::withRevision();
$article->body = 'Text body of an amazing article';
$article->save();
class Article extends Model
{
public $divergentRelations = [
'quoted_id' => 'quotedauthors',
];
public function quotedAuthors()
{
return $this->belongsTo(QuotedAuthors::class, 'quoted_id');
}
}
class QuotedAuthor extends Model
{
public function articles()
{
return $this->hasMany(Article::class);
}
}
...
$newQuotedAuthor = QuotedAuthor::create(['name' => 'New Quoted Author']);
$article->quoted_id = $newQuotedAuthor->id;
$article->save();
$revision = $article->revisionHistory()->first();
$revision->newValue() = 'New Quoted Author';
class Article extends Model
{
public function quotedAuthors()
{
return $this->belongsTo(QuotedAuthors::class, 'quoted_id');
}
}
class QuotedAuthor extends Model
{
public function articles()
{
return $this->hasMany(Article::class);
}
}
...
$newQuotedAuthor = QuotedAuthor::create(['name' => 'New Quoted Author']);
$article->quoted_id = $newQuotedAuthor->id;
$article->save();
$revision = $article->revisionHistory()->first();
$revision->newValue() = 1 ;