Download the PHP package zbiller/laravel-revisions without Composer

On this page you can find all versions of the php package zbiller/laravel-revisions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-revisions

Package discontinued! Check out VARBOX.IO instead.

Unfortunately this package is now discontinued.
Please check out Varbox (Laravel Admin Panel) for this functionality and much more.

Thank you!


Create revisions for any Eloquent model along with its relationships

Build Status StyleCI Scrutinizer Code Quality

Overview

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

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

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

Install the package via Composer (for Laravel 5.8):

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

Publish the config file with:

Publish the migration file with:

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

Setup

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:

Step 2

Inside the revisions.php config file, write the full namespace of your User model class for the user_model config key.

By default, this value is the FQN of Laravel's User model class (\App\User). You can also leave this NULL if your application doesn't have the concept of users.

This bit is used by the Neurony\Revisions\Traits\HasRevisions trait to know who created which revisions.

Usage

Fetch revisions

You can fetch a model record's revisions by using the revisions() morph to many relation present on the Neurony\Revisions\Traits\HasRevisions trait.

Create revisions (automatically)

Once you've used the Neurony\Revisions\Traits\HasRevisions trait in your Eloquent models, each time you update a model record, a revision containing its original attribute values will be created automatically using the updated Eloquent event:

Alternatively, you can also store a revision each time you create a new model record, by using the created Eloquent event
(see Customisations)

Create revisions (manually)

If you ever need it, you can also create a revision manually, by using the saveAsRevision() method from the Neurony\Revisions\Traits\HasRevisions trait:

Rollback to a past revision

You can rollback the model record to one of its past revisions by using the rollbackToRevision() method.

Customisations

Enable revisioning on create

By default, when creating a new model record, a revision will not be created, because the record is fresh and it's at its first state. However, if you wish to create a revision when creating the model record, you can do so by using the enableRevisionOnCreate() method in your definition of the getRevisionOptions() method.

Limit the revisions

You can limit the number of revisions each model record can have by using the limitRevisionsTo() method in your definition of the getRevisionOptions() method.

This prevents ending up with thousands of revisions for a heavily updated record.

When the limit is reached, after creating the new (latest) revision, the script automatically removes the oldest revision that model record has.

Revision only certain fields

If you don't want to revision all the model's fields (attributes), you can manually specify which fields you wish to store when creating a new revision, by using the fieldsToRevision() method in your definition of the getRevisionOptions() method.

Please note that the fields omitted won't be stored when creating the revision, but when rolling back to a revision, those ignored fields will become null / empty for the actual model record.

Exclude certain fields from being revisioned

Opposed to the fieldsToRevision() method, if you want to exclude certain fields when making a revision of an Eloquent model, use the fieldsToNotRevision() method in your definition of the getRevisionOptions() method

Please note that the fieldsToRevision() takes precedence over the fieldsToNotRevision().
Don't use both of these methods in the same definition of the getRevisionOptions method.

Please note that the fields omitted won't be stored when creating the revision, but when rolling back to a revision, those ignored fields will become null / empty for the actual model record.

Include timestamps when creating a revision

By default, when creating a revision, the actual model's timestamps are automatically excluded from the actual revision data.

If you'd like to store the model's timestamps when creating a revision, please use the withTimestamps() method in your definition of the getRevisionOptions() method.

Revision relationships alongside the model record

More often than not you will want to create a full copy in time of the model record and this includes revisioning its relations too (especially child relations).

You can specify what relations to be revisioned alongside the model record by using the relationsToRevision() method in your definition of the getRevisionOptions() method.

Please note that when rolling back the model record to a past revision, the specified relations will also be rolled back to their state when that revision happened (this includes re-creating a relation record from ground up if it was force deleted along the way, or deleting any future added related records up until the revision checkpoint).

Disable creating a revision when rolling back

By default, when rolling back to a past revision, a new revision is automatically created. This new revision contains the model record's state before the rollback happened.

You can disable this behavior by using the disableRevisioningWhenRollingBack() method in your definition of the getRevisionOptions() method.

Events

The revision functionality comes packed with two Eloquent events: revisioning and revisioned

You can implement these events in your Eloquent models as you would implement any other Eloquent events that come with the Laravel framework.

Credits

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

License

The MIT License (MIT). Please see LICENSE for more information.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.


All versions of laravel-revisions with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2.5
illuminate/contracts Version ^7.0
illuminate/support Version ^7.0
illuminate/database Version ^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package zbiller/laravel-revisions contains the following files

Loading the files please wait ....