Download the PHP package plank/laravel-checkpoint without Composer

On this page you can find all versions of the php package plank/laravel-checkpoint. 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-checkpoint

Laravel Checkpoint

Latest Version on Packagist GitHub Tests Action Status Total Downloads

Table of Contents

Why Use This Package

Do you need to store the state of how your models change over time? Do you need a way to query and view the state of your models at different points in time? If the answer is yes, then this package is for you!

Installation

You can install the package via composer:

Concepts

Timelines

A is a way to have completely separate views of your content. A allows you to filter the s of your models based on the it belongs to.

Table:

Field Type Required Default
id bigIncrements Increment
timeline_id unsignedBigInteger
title string
checkpoint_date timestamp
created_at timestamp
updated_at timestamp

Checkpoints

A is a point in time which is of interest. A allows you to filter the s of your models based on the 's .

Table:

Field Type Required Default
id bigIncrements Increment
timeline_id unsignedBigInteger
title string
checkpoint_date timestamp
created_at timestamp
updated_at timestamp

Revisions

A references a record of a in a particular state at a particular point in time. When this package is enabled, and you use the trait on a Model, the concept of an instance of a Model in Laravel changes. Since we want to store s of a Model, and have them searchable in their different states, the notion that an Entity (instance of a Model) is associated with exactly one id, is no longer correct. Each of a Model has its own unique id in the table, even though it represents the same Entity.

The same entity is linked via the field.

Table:

Field Type Required Default
id bigIncrements Increment
revisionable_id unsignedBigInteger
revisionable_type string
original_revisionable_id unsignedBigInteger
latest boolean true
metadata json null
previous_revision_id unsignedBigInteger null
checkpoint_id unsignedBigInteger null
created_at timestamp
updated_at timestamp

Usage

Revisioning Models

To have a model be revisioned, all you need to do is have it use the trait.

What gets Revisioned?

This package handles revisioning by creating a new row for a Model in the database every time it changes state in a meaningful way. When a new is created, the package will also recursively duplicate all Models related via child relationships, and will create new many-to-many relationships in pivot tables.

Start Revisioning Command

If you have an existing project with Models already populated in the database, the
command will begin revisioning all of the Models which are using the trait.

Query Scopes

The way this package achieves it's goal is by adding scopes (and one global scope) to query models that have revisions.

Active Checkpoint

By setting the active checkpoint , all queries for revisioned models will be scoped to that . Also, when there is an active checkpoint set, any new revisions that get created will be associated with that .

at($moment)

This is the default global query scope added to all queries on a Model with s.

This query scope will limit the query to return the Model whose has the max primary key, where the was created at or before the given moment.

The moment can either be an instance of a
using its field, a string representation of a date or a instance.

since($moment)

This query scope will limit the query to return the Model whose has the max primary key, where the was created after the given moment.

The moment can either be an instance of a using its field, a string representation of a date or a instance.

temporal($upper, $lower)

This query scope will limit the query to return the Model whose has the max primary key created at or before . This method can also limit the query to the Model whose revision has the max primary key created after .

Each argument operates independently of each other and and can either be an instance of a using its field, a string representation of a date or a instance.

withoutRevisions()

This query scope is used to query the models without taking revisioning into consideration.

Dynamic Relationships

Inspired by https://reinink.ca/articles/dynamic-relationships-in-laravel-using-subqueries, this package supplies a few dynamic relationships as a convenience for navigating through a model's revision history. The following scopes will run subqueries to get the additional columns and eagerload the corresponding relations, saving you the hassle of caching them on each of the tables for your revisionable models. As a fallback when these scopes are not applied, we use get mutators to run queries and fetch the same columns, making sure the relations are always available but at the expense of running a bit more queries. NOTE: when applying these scopes, you will have extra columns in your models attributes, any update or insert operations will not work.

withNewestAt($until, $since)

This scope will retrieve the id of the newest model given the until / since constraints. Stored in the newest_id attribute, this allows you to use ->newest() relation as a quick way to navigate to that model. Defaults to the newest model in the revision history.

withNewest()

This scope is a shortcut of withNewestAt with the default parameters. Uses the same attribute, mutator and relation.

withInitial()

This scope will retrieve the id of the initial model from its revision history. Stored in the initial_id attribute, this allows you to use ->initial() relation as a quick way to navigate to that first item in the revision history.

withPrevious()

This scope will retrieve the id of the previous model from its revision history. Stored in the previous_id attribute, this allows you to use ->previous() relation as a quick way to navigate to that previous item in the revision history.

withNext()

This scope will retrieve the id of the next model from its revision history. Stored in the next_id attribute, this allows you to use ->next() relation as a quick way to navigate to that next item in the revision history.

Revision Metadata & Uniqueness

As a workaround to some package compatibility issues, this package offers a convenient way to store the values of some columns as on the table. The primary use-case for this feature is to deal with columns or indexes which force some sort of uniqueness constraint on the Model's table.

For example, imagine a model we wish to revision and it has a field which needs to be unique. Since multiple instances of the same need to exist as revisions, there would be duplicated . By specifying the field in the of the Model, this package will manage this field by storing it as metadata on the . The package achieve's this by overriding the method on the model, to retrieve the value of from the . When saving a new of the the will automatically be saved on the field of the revision and set as null on the .

Ignored Fields

When updating the fields of a Model, some fields may not warrant creating a new of the Model. You can prevent a new from being created when specific fields are updated by setting the array on the model being revisioned.

Should Revision

If you have more complex cases where you may not want to create a new when updating a Model, you can override the on the Model being revisioned. When this method returns a truthy value, a new will be created when updating, and when it returns a falsy value it will not.

Excluded Columns

When creating a new of a Model there may be some fields which do not make sense to have their values copied over. In those cases you can add those values to the array on the Model you are revisioning. Some operations like deleting / restoring / revisioning children require a full copy and will ignore this option.

Excluded Relations

When creating a new of a Model there may be relations which do not make sense to duplicate. In those cases you can add the names of the relations to the array on the Model you are revisioning. Excluding all relations to the s and other related s are handled by the package.

Testing

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 [email protected] instead of using the issue tracker.

Credits

License

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


All versions of laravel-checkpoint with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1.3|^8.0
ext-json Version *
illuminate/support Version 5.8.*|^6.0|^7.0|^8.0|^9.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 plank/laravel-checkpoint contains the following files

Loading the files please wait ....