48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Modules\Mall\Traits;
|
|
|
|
use Modules\Mall\Facades\Workflow;
|
|
|
|
trait WithWorkflow
|
|
{
|
|
|
|
/**
|
|
* Notes : 执行某一步骤
|
|
* @Date : 2021/5/8 5:36 下午
|
|
* @Author : < Jason.C >
|
|
* @param $transition
|
|
* @param null $workflow
|
|
* @return mixed
|
|
*/
|
|
public function apply($transition, $workflow = null)
|
|
{
|
|
return Workflow::get($this, $workflow)->apply($this, $transition);
|
|
}
|
|
|
|
/**
|
|
* Notes : 是否可以执行
|
|
* @Date : 2021/5/8 5:36 下午
|
|
* @Author : < Jason.C >
|
|
* @param $transition
|
|
* @param null $workflow
|
|
* @return mixed
|
|
*/
|
|
public function can($transition, $workflow = null)
|
|
{
|
|
return Workflow::get($this, $workflow)->can($this, $transition);
|
|
}
|
|
|
|
/**
|
|
* Notes : 可执行的操作
|
|
* @Date : 2021/5/8 5:37 下午
|
|
* @Author : < Jason.C >
|
|
* @param null $workflow
|
|
* @return mixed
|
|
*/
|
|
public function transitions($workflow = null)
|
|
{
|
|
return Workflow::get($this, $workflow)->getEnabledTransitions($this);
|
|
}
|
|
|
|
} |