PHPackages                             zbiller/laravel-revisions - 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. zbiller/laravel-revisions

Abandoned → [varbox/varbox](/?search=varbox%2Fvarbox)Library[Database &amp; ORM](/categories/database)

zbiller/laravel-revisions
=========================

Create multiple revisions of any Eloquent model record along with its underlying relationships

5.0.0(5y ago)1644223[1 issues](https://github.com/Neurony/laravel-revisions/issues)[1 PRs](https://github.com/Neurony/laravel-revisions/pulls)MITPHPPHP ^7.2.5

Since Feb 18Pushed 3y ago7 watchersCompare

[ Source](https://github.com/Neurony/laravel-revisions)[ Packagist](https://packagist.org/packages/zbiller/laravel-revisions)[ RSS](/packages/zbiller-laravel-revisions/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (9)Dependencies (5)Versions (10)Used By (0)

Package discontinued! Check out VARBOX.IO instead.
==================================================

[](#package-discontinued-check-out-varboxio-instead)

Unfortunately this package is now discontinued.
Please check out [Varbox](https://varbox.io) (Laravel Admin Panel) for this functionality and much more.

- Buy:
- Docs:
- Demo:
- Repo

Thank you!

---

### Create revisions for any Eloquent model along with its relationships

[](#create-revisions-for-any-eloquent-model-along-with-its-relationships)

[![Build Status](https://camo.githubusercontent.com/3855ef15bebc2d52360a87d1562356e97c09e5b4e04a41d258423db221849d7a/68747470733a2f2f7472617669732d63692e6f72672f4e6575726f6e792f6c61726176656c2d7265766973696f6e732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Neurony/laravel-revisions)[![StyleCI](https://camo.githubusercontent.com/638bbdbc4467b5d4c320e6658daf7b27327195af925a71df1795f84c9c6ea656/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3137303931353538392f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/170915589)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/e90865ffcd8b8cba86a6177bc66733295cc6cb87a81a594ae0b9c9e53531a101/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4e6575726f6e792f6c61726176656c2d7265766973696f6e732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Neurony/laravel-revisions/?branch=master)

- [Overview](#overview)
- [Installation](#installation)
- [Setup](#setup)
- [Usage](#usage)
- [Customisations](#customisations)
- [Events](#events)

### Overview

[](#overview)

This package allows you to create revisions for any Eloquent model record along with its underlying relationships.

- When a revision is created, it gets stored inside the `revisions` database table.
- Revisions are created automatically on model update, using the `updated` Eloquent event
- Revisions can also can be created manually by using the `saveAsRevision()`
- When a record is force deleted, all its revisions will also be removed automatically, using the `deleted` Eloquent event

As already mentioned, this package is capable of revisioning entire relationships alongside the model record.

**The cool part is that it's also capable of re-creating the relationships records from ground up, if they were force deleted along the way, during the lifetime of that model record.**

Relationship types that can be revisioned: `hasOne`, `morphOne`, `hasMany`, `morphMany`, `belongsToMany`, `morphToMany`

### Installation

[](#installation)

Install the package via Composer (for **Laravel 6.0 and above**):

```
composer require neurony/laravel-revisions

```

Install the package via Composer (for **Laravel 5.8**):

```
composer require neurony/laravel-revisions:3.1.0

```

Install the package via Composer (for **Laravel 5.7 and below**):

```
composer require neurony/laravel-revisions:2.0.0

```

Publish the config file with:

```
php artisan vendor:publish --provider="Neurony\Revisions\ServiceProvider" --tag="config"

```

Publish the migration file with:

```
php artisan vendor:publish --provider="Neurony\Revisions\ServiceProvider" --tag="migrations"

```

After the migration has been published you can create the `revisions` table by running:

```
php artisan migrate

```

### Setup

[](#setup)

##### Step 1

[](#step-1)

Your Eloquent models should use the `Neurony\Revisions\Traits\HasRevisions` trait and the `Neurony\Revisions\Options\RevisionOptions` class.

The trait contains an abstract method `getRevisionOptions()` that you must implement yourself.

Here's an example of how to implement the trait:

```
