Giter Site home page Giter Site logo

laravel-enso / versioning Goto Github PK

View Code? Open in Web Editor NEW
35.0 8.0 9.0 50 KB

Prevents update conflicts in Laravel

Home Page: https://docs.laravel-enso.com/packages/versioning.html

License: MIT License

PHP 100.00%
laravel-enso versioning trait laravel optimistic-updates optimistic-locking

versioning's Introduction

Versioning

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 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

Contributions

are welcome. Pull requests are great, but issues are good too.

License

This package is released under the MIT license.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.