oobook / snapshot
Create a snapshot on the stage of creating record and always keeps the currently created data.
Requires
- php: >=8.1
- oobook/manage-eloquent: ^1.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- doctrine/dbal: ^3.9
- friendsofphp/php-cs-fixer: ^3.64
- orchestra/testbench: ^7.0|^8.23.4|^9.0
- phpunit/phpunit: ^9.0|^10.0.7|^11.0
README
Eloquent Snapshot
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.
Installation
You can install the package via composer:
composer require oobook/snapshot
Publish config
Create the snapshot config file under config/ folder using artisan
php artisan vendor:publish --tag="snapshot-config"
Usage
<?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 = []; }
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email oguz.bukcuoglu@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.