Codacy Badge StyleCI License Total Downloads Latest Stable Version

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


The package does not installed by default in Enso.

To install:

  1. add the package using composer composer require laravel-enso/versions
  2. use the Versions trait on the models you want versioning on
  3. ensure the models/tables have the required column, to hold the version
  4. 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 Versions trait 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 ConflictHttpException if 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.