PHP code example of lukasjankowski / laravel-revision
1. Go to this page and download the library: Download lukasjankowski/laravel-revision 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/ */
lukasjankowski / laravel-revision example snippets
use Illuminate\Database\Eloquent\Model;
use LukasJankowski\Revision\Traits\HasRevision;
class Post extends Model
{
use HasRevisions;
// ...
}
use Illuminate\Foundation\Auth\User as Authenticatable;
use LukasJankowski\Revision\Traits\IsReviser;
class User extends Authenticatable
{
use IsReviser;
// ...
}
use Illuminate\Database\Eloquent\Model;
use LukasJankowski\Revision\Traits\HasRevision;
class Post extends Model
{
use HasRevisions;
/**
* The fields, which will not be logged in the revisions.
*
* @var array
*/
protected $revisionExclude = [
'password', 'remember_token',
];
/**
* The threshold, which will limit the revisions to that number.
*
* @var int
*/
protected $revisionThreshold = 123;
// ...
}
$post = App\Post::find(1);
$post->revisions; // Returns all revisions made to this record in a collection.
$post = App\Post::find(1);
$post->revisions()->with('revisers')->get(); // Same as above, but eager load the ones, who performed the revision.
$user = App\User::find(1);
$user->revised; // Returns all revisions made by this record in a collection.
$user = App\User::find(1);
$user->revised()->with('revisions')->get();
// Same as above, but eager load the models on which the revisions were performed.