Download the PHP package aventure-cloud/eloquent-status-recorder without Composer
On this page you can find all versions of the php package aventure-cloud/eloquent-status-recorder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download aventure-cloud/eloquent-status-recorder
More information about aventure-cloud/eloquent-status-recorder
Files in aventure-cloud/eloquent-status-recorder
Package eloquent-status-recorder
Short Description Eloquent model's status management with history
License MIT
Informations about the package eloquent-status-recorder
Eloquent Status Recorder
Any eloquent model can have Status management with just one trait. Declare status statically but store status history four your models in the database.
- Author: Valerio Barbera - [email protected]
- Author Website: www.aventuresrl.com
Install
composer require aventure-cloud/eloquent-status-recorder
Config
Publish configuration file in your project:
php artisan vendor:publish --provider="AventureCloud\EloquentStatusRecorder\EloquentStatusRecorderServiceProvider" --tag="config"
Migration
We provide a migration script to create statuses
table.
To publish migration script execute:
php artisan vendor:publish --provider="AventureCloud\EloquentStatusRecorder\EloquentStatusRecorderServiceProvider" --tag="migrations"
And run with artisan command:
php artisan migrate --path=/database/migrations
Use
Attach HasStatus
trait to your models and configure statuses values
for each models indipendently.
Utility methods
Auto-run callbacks
In some cases, you need to do something after a specific status is set.
For example, send an mail after an order is "shipped". This package
invokes a method after status change by the convention of
on + status_name (camel cased)
:
Events
Every time a status change happen two event will fire with attached the current eloquent model instance and the given status:
- StatusChanging (Before status is saved)
- StatusChanged (After status change is performed)