PHPackages                             bidzm/eloquent-state-machine - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. bidzm/eloquent-state-machine

ActiveLibrary[Database &amp; ORM](/categories/database)

bidzm/eloquent-state-machine
============================

Eloquent State Machine

1.0.5(8y ago)120.6k↓50%MITPHPPHP &gt;=5.5.9

Since Aug 19Pushed 8y agoCompare

[ Source](https://github.com/abidnurulhakim/eloquent-state-machine)[ Packagist](https://packagist.org/packages/bidzm/eloquent-state-machine)[ Docs](https://github.com/abidnurulhakim/laravel-state-machine)[ RSS](/packages/bidzm-eloquent-state-machine/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (8)Used By (0)

laravel-state-machine
=====================

[](#laravel-state-machine)

Eloquent State Machine

Install through Composer

```
composer require bidzm/eloquent-state-machine

```

Usage
-----

[](#usage)

Just add `Bidzm\StateMachine` to your eloquent model.

```
namespace App;

use Illuminate\Database\Eloquent\Model;
use Bidzm\StateMachine;

class Message extends Model
{
    use StateMachine;
    protected $fieldState = 'state'; // attribute name that use as state. Default `state`;
    protected $initialState = 'initiated'; // initial state. Default `initiated`;
    protected $transitions = [
        [
            'from' => ['initiated'], // Previous state
            'to' => 'queued', // State name
            'on' => 'queue' // Action name
        ],
        [
            'from' => ['queued'], // Previous state
            'to' => 'finished', // State name
            'on' => 'finish' // Action name
        ],
    ];
}

```

There some function that you can use

```
