Prevents update conflicts using the optimistic lock pattern in Laravel.
This package can work independently of the Enso ecosystem.
For live examples and demos, you may visit laravel-enso.com
The package does not installed by default in Enso.
- add the package using composer
composer require laravel-enso/versions
- use the
Versionstrait on the models you want versioning on
- ensure the models/tables have the required column, to hold the version
- add and set the
protected $versioningAttribute = 'version'attribute on the versioned models
- the package uses a column on your model to store the version (the column name is configurable)
- by using the
Versionstrait on a model, versioning is handled automatically
- by default the trait sets the version to 1, just before the model is created
- the version attribute can be set by using
protected $versioningAttribute = 'customVersionAttribtue'on the model
- the trait can be used on models that already have records in the database, the versioning will start with the first retrieval of those models
- throws a
ConflictHttpExceptionif the version does not match on update
are welcome. Pull requests are great, but issues are good too.
This package is released under the MIT license.