"davin-bao/workflow": "v1.0"
Workflow package provides a simple way to add audit flow to Laravel5.
In the require
key of composer.json
file add the following
"davin-bao/workflow": "dev-master"
Run the Composer update comand
$ composer update
In your config/app.php
add 'DavinBao\Workflow\WorkflowServiceProvider'
to the end of the $providers
array
'providers' => array(
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
'Illuminate\Auth\AuthServiceProvider',
...
'DavinBao\Workflow\WorkflowServiceProvider',
),
At the end of config/app.php
add 'Workflow' => 'DavinBao\Workflow\WorkflowFacade'
to the $aliases
array
'aliases' => array(
'App' => 'Illuminate\Support\Facades\App',
'Artisan' => 'Illuminate\Support\Facades\Artisan',
...
'Workflow' => 'DavinBao\Workflow\WorkflowFacade',
),
Now generate the Workflow migration
$ php artisan workflow:migration
It will generate the <timestamp>_workflow_setup_tables.php
migration. You may now run it with the artisan migrate command:
Open: <timestamp>_workflow_setup_tables.php
change " {{ '<?php' }} " to " <?php "
$ php artisan migrate
After the migration, workflow tables will be present.
$ php artisan workflow:controllers
$ php artisan workflow:routes
class Entry extends Eloquent {
use \DavinBao\Workflow\HasFlowForResource;
}
public function getLogTitle()
{
return $this->entry_title;
}
public function getLogContent()
{
return $this->entry_content;
}
class AdminEntryController extends AdminController {
use \DavinBao\Workflow\HasFlowForResourceController;
}
Route::get('entrys/{entry}/binding', 'AdminEntrysController@getBindingFlow');
Route::post('entrys/{entry}/binding', 'AdminEntrysController@postBindingFlow');
Route::get('entrys/{entry}/audit', 'AdminEntrysController@getAudit');
Route::post('entrys/{entry}/audit', 'AdminEntrysController@postAudit');
Set the propertly values to the config/auth.php
and davin-bao/workflow/src/config/config.php
.
if(isset($entry->isBinding)) {///is binding, do something }
$entry->status()
@if(isset($entry->isBinding))
{{ Workflow::makeFlowGraph($entry->flow(), $entry->orderID()) }}
@endif
@if(isset($entry->isBinding))
{{ Workflow::makeAuditDetail($entry) }}
@endif
if(isset($entry->isBinding) && $entry->isMeAudit()) { /// show audit button }