1. Go to this page and download the library: Download cape-and-bay/versionable 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/ */
cape-and-bay / versionable example snippets
use CapeAndBay\Versionable\Versionable;
class Post extends Model
{
use Versionable;
# Prevents versioning Post if only the "is_active" column is updated.
protected array $dont_version = ['is_active'];
}
use CapeAndBay\Versionable\Versionable;
use CapeAndBay\Versionable\VersionableInterface;
use Illuminate\Database\Eloquent\Model;
class User extends Model implements VersionableInterface
{
use Versionable;
public function onNewVersionCreate(Model $model) : bool
{
// Create new version if email is not "[email protected]"
return $model->email !== '[email protected]';
}
}
$post->versions; // all versions
$post->latestVersion(); // latest version
$post->versions->first(); // first version
bash
php artisan migrate
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.