Skip to content

OoBook/snapshot

Repository files navigation

Modulariy Logo

Eloquent Snapshot

Latest Version on Packagist Total Downloads GitHub Actions

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.