Download the PHP package norotaro/enumata-recorder without Composer
On this page you can find all versions of the php package norotaro/enumata-recorder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download norotaro/enumata-recorder
More information about norotaro/enumata-recorder
Files in norotaro/enumata-recorder
Package enumata-recorder
Short Description Automatically records all Enumata transitions
License MIT
Informations about the package enumata-recorder
Enumata Recorder
Automatically records all Enumata transitions.
Description
This package allow you to automatically record logs of all states a model with Enumata may have and query this logs to take specific actions accordingly.
Installation
Install the package via Composer:
Then run the migrations:
Configuration
In a model configured to use Enumata (see documentation) we only need to add the LogTransitions
trait:
That's it. Now all transitions will be recorded automatically using the enumata_state_logs
table that was created when installing the package.
Querying Logs
Get full history of transitioned states:
The stateLogs() method returns an Eloquent relationship that can be chained as any Query Builder to further down the results. You also have some scopes available.
Scopes
fromState($state)
toState($state)
forField($field)
This is util if you have more that one field that use states.
For example, having this model:
We can access the logs for each field in this way:
Alternatively we can pass a param to stateLogs()
with the name of the field to get the same result:
Testing
To run the test suite:
Inspiration
This package was inspired by asantibanez/laravel-eloquent-state-machines.
LICENSE
The MIT License (MIT). Please see License File for more information.