Download the PHP package jpnut/eloquent-versioning without Composer

On this page you can find all versions of the php package jpnut/eloquent-versioning. 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 eloquent-versioning

Versions for Eloquent models

Latest Version Quality Score StyleCI

This package provides a trait that adds versions to an Eloquent model (forked from proai/eloquent-versioning).

New versions are created whenever a model is updated. Versions are stored in a separate table for each model (e.g. user_versions).

The package allows for a mixture of versioned and non-versioned attributes.

By default, queries are scoped to merge records in the parent table with the latest version. Additional scopes exist to merge records at a particular version or point in time.

Installation

This package can be installed through Composer.

Usage

To add versions to your model you must:

  1. Implement the JPNut\Versioning\Versionable interface.
  2. Use the JPNut\Versioning\VersionableTrait trait.
  3. Add the getVersionableOptions method to your model. This method must return an instance of JPNut\Versioning\VersionOptions. You should define which attributes you would like to version by calling setVersionableAttributes and passing an array of attributes:

  4. Add the version column to the table of the model which you wish to version. This keeps track of the current version.

  5. Create a table to contain the versions. This table should contain a reference to the parent model (parent_id), the version number version, all versionable attributes (email, city), and the created_at timestamp.

It is assumed that the version table name takes the form {entity}_versions where entity is the singular form of the entity noun (e.g. users and user_versions). It is possible to override this and all column names by calling the relevant method on the options object (the following shows the default settings).

Example

You can retrieve the model at a specific version by using the atVersion scope

You can retrieve the model at a specific point in time by using the atTime scope

Note that this will attempt to find the last version created before the time supplied. If there are no such versions, the method will return null.

You can disable the global scope by using the withoutVersion scope

You can obtain all versions in the form of a relationship by calling the versions property (or method) on a model instance

Note that by default a generic Version model is used. You can change this model by overwriting the versions method and returning your own HasMany relationship.

You can revert to a previous version by calling the changeVersion() method with the desired version as an argument.

Note that this creates a new version with the same versionable attribute values as the version specified (rather than changing the value of the version column in the parent table).

Tests

The package contains some integration tests, set up with Orchestra. The tests can be run via phpunit.

Contributing

Create a Pull Request!

Alternatives

License

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


All versions of eloquent-versioning with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4
laravel/framework Version ^6.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 jpnut/eloquent-versioning contains the following files

Loading the files please wait ....