PHPackages                             oobook/snapshot - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. oobook/snapshot

ActiveLibrary[Database &amp; ORM](/categories/database)

oobook/snapshot
===============

Create a snapshot on the stage of creating record and always keeps the currently created data.

v2.2.0(1mo ago)23.3k2MITPHPPHP &gt;=8.1CI passing

Since Sep 24Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/OoBook/snapshot)[ Packagist](https://packagist.org/packages/oobook/snapshot)[ Docs](https://github.com/oobook/snapshot)[ RSS](/packages/oobook-snapshot/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (12)Versions (16)Used By (2)

[![Modulariy Logo](./snapshot.png)](./snapshot.png)

Eloquent Snapshot
=================

[](#eloquent-snapshot)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a4e3487b4b0dda76636f65e1124de0a3bfe3a1d0c6fd6befd76f64604c3d70ad/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f6f626f6f6b2f736e617073686f742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oobook/snapshot)[![Total Downloads](https://camo.githubusercontent.com/df3c9cb9da02b21dce3fb52ce6f3f75b66657830899c09d67834e6bbeb1c5633/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f6f626f6f6b2f736e617073686f742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oobook/snapshot)[![GitHub Actions](https://github.com/oobook/snapshot/actions/workflows/main.yml/badge.svg)](https://github.com/oobook/snapshot/actions/workflows/main.yml/badge.svg)

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
------------

[](#installation)

You can install the package via composer:

```
composer require oobook/snapshot
```

#### Publish migrations

[](#publish-migrations)

Create the snapshot migrations file under database/migrations/ folder using **artisan**

```
php artisan vendor:publish --tag="snapshot-migrations"

```

#### Publish config

[](#publish-config)

If you would like to to change snapshot table name, create the snapshot config file under config/ folder using **artisan**

```
php artisan vendor:publish --tag="snapshot-config"

```

Usage
-----

[](#usage)

The `HasSnapshot` trait allows you to create point-in-time copies (snapshots) of your Eloquent models while maintaining relationships. It provides both snapshot and sync capabilities for attributes and relationships.

### Basic Setup

[](#basic-setup)

```
