https://github.com/cgdsoftware/versioning
Prevents update conflicts in Laravel
https://github.com/cgdsoftware/versioning
Last synced: 5 months ago
JSON representation
Prevents update conflicts in Laravel
- Host: GitHub
- URL: https://github.com/cgdsoftware/versioning
- Owner: cgdsoftware
- License: mit
- Fork: true (laravel-enso/versioning)
- Created: 2022-08-31T15:09:42.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-05-14T20:06:02.000Z (about 3 years ago)
- Last Synced: 2025-06-07T03:37:32.677Z (about 1 year ago)
- Language: PHP
- Homepage: https://docs.laravel-enso.com/packages/versioning.html
- Size: 48.8 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Versioning
[](https://www.codacy.com/gh/laravel-enso/versioning?utm_source=github.com&utm_medium=referral&utm_content=laravel-enso/versioning&utm_campaign=Badge_Grade)
[](https://github.styleci.io/repos/134861936)
[](https://packagist.org/packages/laravel-enso/versioning)
[](https://packagist.org/packages/laravel-enso/versioning)
[](https://packagist.org/packages/laravel-enso/versioning)
Prevents update conflicts using the optimistic lock pattern in Laravel
This package can work independently of the [Enso](https://github.com/laravel-enso/Enso) ecosystem.
For live examples and demos, you may visit [laravel-enso.com](https://www.laravel-enso.com)
## Installation
1. install the package `composer require laravel-enso/versioning`
2. run the migrations
3. use the `Versionable` trait on the models you want versioning on.
By default, the version value is kept in a 'version' attribute, but this can be customized (see below).
## Features
- the package creates a `versionings` table where it holds versions for all the versionable models
- by using the `Versionable` trait on a model, versioning is handled automatically
- by default the trait appends a `version` attribute after the model is retrieved, used for tracking versions and expects the same attribute to be present on the model when the update is called
- the default versioning attribute can be customized by using `protected $versioningAttribute = 'customVersionAttribte'` on the model
- the trait can be used on models that already have records in the database, the versioning starts with the first retrieval of those models
- when a versionable model is deleted, its versioning is deleted also. If the model uses `SoftDeletes`, the versioning is not deleted, unless doing a `forceDelete`
- throws a `ConflictHttpException` if the version does not match on update
- tests are included with the package
## Configuration & Usage
Be sure to check out the full documentation for this package available at [docs.laravel-enso.com](https://docs.laravel-enso.com/backend/versioning.html)
## Contributions
are welcome. Pull requests are great, but issues are good too.
## License
This package is released under the MIT license.