PHP code example of msnisha / laraflow
1. Go to this page and download the library: Download msnisha/laraflow library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
msnisha / laraflow example snippets
composer
php artisan migrate
[
'property_path' => 'last_step',
'steps' => [
[
'text' => 'Open',
'extra' => []
],
[
'text' => 'In Progress',
'extra' => []
],
[
'text' => 'Resolved',
'extra' => []
],
[
'text' => 'Reopen',
'extra' => []
],
[
'text' => 'Closed',
'extra' => []
],
],
'transitions' => [
[
'from' => 0,
'to' => 1,
'text' => 'Start Progress',
'extra' => [],
'callbacks' => [
'pre' => [
'App\\TestPreCallback'
],
'post' => [
'App\\TestPostCallback'
]
],
'validators' => [
[
'title' => 'numeric',
'assignee_id' => 'tra' => [
'fromPort' => 'R',
'toPort' => 'R',
'points' => []
],
'callbacks' => [
'pre' => [],
'post' => []
],
'validators' => []
],
[
'from' => 1,
'to' => 4,
'text' => 'Close Issue',
'extra' => [],
'callbacks' => [
'pre' => [],
'post' => []
],
'validators' => []
],
[
'from' => 3,
'to' => 4,
'text' => 'Close Issue',
'extra' => [],
'callbacks' => [
'pre' => [],
'post' => []
],
'validators' => []
],
],
$table->string('last_state');
use szana8\Laraflow\Traits\Flowable;
class SampleClass extends Model {
use Flowable;
$object->transiton($new_status);
$object->save();
LaraflowEvents::PRE_TRANSITION
LaraflowEvents::POST_TRANSITION
LaraflowEvents::CAN_TRANSITION