PHPackages                             linkbee/state-workflow - 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. [Framework](/categories/framework)
4. /
5. linkbee/state-workflow

ActiveLibrary[Framework](/categories/framework)

linkbee/state-workflow
======================

State Management workflow for Laravel, this package is fork form RingierIMU/state-workflow

2.0(5y ago)024MITPHPPHP &gt;7.2.5

Since Dec 27Pushed 5y ago1 watchersCompare

[ Source](https://github.com/ptyz030529/state-workflow)[ Packagist](https://packagist.org/packages/linkbee/state-workflow)[ Docs](https://github.com/ptyz030529/state-workflow)[ RSS](/packages/linkbee-state-workflow/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (10)Versions (2)Used By (0)

Laravel State workflow
======================

[](#laravel-state-workflow)

Implement [Symfony Workflow](https://symfony.com/doc/current/components/workflow.html) component in Laravel

A workflow consist of state and actions to get from one place to another. The actions are called transitions which describes how to get from one state to another.

Installation
------------

[](#installation)

```
$ composer require linkbee/state-workflow

```

For Laravel versions lower than 5.5, this step is important after running above script.

- Open your config/app.php file and add custom service provider:

```
Linkbee\StateWorkflow\StateWorkflowServiceProvider::class
```

Publish `config/workflow.php` file

```
$ php artisan vendor:publish --provider="Linkbee\StateWorkflow\StateWorkflowServiceProvider"
```

Run migrations

```
$ php artisan migrate

```

Configuration
-------------

[](#configuration)

1. Open `config/workflow.php` and configure it

```
// this should be your model name in camelcase. eg. PropertyListing::Class => propertyListing
'post' => [
        // class of your domain object
        'class' => \App\Post::class,

        // Register subscriber for this workflow which contains business rules. Uncomment line below to register subscriber
        //'subscriber' => \App\Listeners\UserEventSubscriber::class,

        // property of your object holding the actual state (default is "current_state")
        //'property_path' => 'current_state', //uncomment this line to override default value

        // list of all possible states
        'states' => [
            'new',
            'pending_activation',
            'activated',
            'deleted',
            'blocked'
        ],

        // list of all possible transitions
        'transitions' => [
            'create' => [
                'from' => ['new'],
                'to' => 'pending_activation',
            ],
            'activate' => [
                'from' => ['pending_activation'],
                'to' =>  'activated',
            ],
            'block' => [
                'from' => ['pending_activation', 'activated'],
                'to' => 'blocked'
            ],
            'delete' => [
                'from' => ['pending_activation', 'activated', 'blocked'],
                'to' =>  'deleted',
            ],
        ],
    ],
```

2. Add `HasWorkflowTrait` to your model class to support workflow

```
