PHP code example of braankoo / eloquent-snapshot

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

    

braankoo / eloquent-snapshot example snippets



use Braankoo\EloquentSnapshot\EloquentSnapshotFacade as Snapshot;

Snapshot::create($model);
Snapshot::create([$model1, $model2]);
Snapshot::create(collect([$model1, $model2]));


use Braankoo\EloquentSnapshot\EloquentSnapshotFacade as Snapshot;
use Braankoo\EloquentSnapshot\EloquentSnapshotFilter;
Snapshot::restore(Model::first()); // Restore the last model snapshot
Snapshot::restore(Model::first(), (new EloquentSnapshotFilter())->first());
Snapshot::restore(Model::first(), (new EloquentSnapshotFilter())->latest());

use Braankoo\EloquentSnapshot\EloquentSnapshotFilter;
use Braankoo\EloquentSnapshot\EloquentSnapshotFacade as Snapshot;
Snapshot::restore(Model::first(), (new EloquentSnapshotFilter())->before(Carbon::now()->subDays(7))->after(Carbon::now()->subDays(30))->first());
bash
php artisan migrate