This package will create easily the snapshots of your eloquent models into another eloquent model. Besides, it retains the relationships as attribute on your projected models.
You can install the package via composer:
composer require oobook/snapshot
Create the snapshot config file under config/ folder using artisan
php artisan vendor:publish --tag="snapshot-config"
<?php
namespace App\Models;
use Oobook\Snapshot\Traits\HasSnapshot;
class MyProduct extends Model
{
use HasSnapshot;
/**
* The source model for the snapshot.
*
* Required
*
* @var Model
*/
public $snapshotSourceModel = YourModel::class;
/**
* Fillable attributes to be copied from the source model.
*
* Optional
*
* @var array
*/
public $snapshotSourceFillable = [];
/**
* Relationships to add to snapshot data.
*
* Optional
*
* @var array
*/
public $snapshotSourceRelationships = [];
}
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email oguz.bukcuoglu@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the Laravel Package Boilerplate.