Download the PHP package jxckaroo/laravel-state-machine without Composer
On this page you can find all versions of the php package jxckaroo/laravel-state-machine. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jxckaroo/laravel-state-machine
More information about jxckaroo/laravel-state-machine
Files in jxckaroo/laravel-state-machine
Package laravel-state-machine
Short Description A simple state machine to handle model transactions, based on a list of pre-defined rules, for Laravel.
License MIT
Homepage https://github.com/jxckaroo/laravel-state-machine
Informations about the package laravel-state-machine
![](./banner.png)
A simple state machine that allows transitioning model states based on pre-defined rules.
Installation
You can install the package via composer:
Run the package migrations:
Usage
Add the Jxckaroo\StateMachine\Stateable
trait to your model(s) that require state management & define your states on your model(s):
States & Rules
Below is an example of a ready-to-go model.
When defining your states, you can specify either one or many rules as above. Your rules must extend Jxckaroo\StateMachine\Contracts\StateRule
and must contain a validate
method as per the below example:
You can also add specific error messages when a validation fails, like so:
These error messages can then be retrieved by calling $model->stateErrors()
after attempting to transition state, resulting in a collection of errors returning, like below:
Model Interactions
Check if a state transition is successful:
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
- Jack Mollart
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.
All versions of laravel-state-machine with dependencies
illuminate/database Version ^5.0 || ^6.0 || ^7.0 || ^8.0
illuminate/support Version ^5.0 || ^6.0 || ^7.0 || ^8.0