2026-02-24 17:57:25 +08:00
|
|
|
<?php
|
|
|
|
|
|
2026-02-24 18:28:23 +08:00
|
|
|
namespace app\model;
|
2026-02-24 17:57:25 +08:00
|
|
|
|
|
|
|
|
use support\Model;
|
|
|
|
|
|
|
|
|
|
class ApprovalFlow extends Model
|
|
|
|
|
{
|
|
|
|
|
protected $table = 'approval_flow';
|
|
|
|
|
|
|
|
|
|
protected $fillable = [
|
|
|
|
|
'business_type',
|
|
|
|
|
'name',
|
|
|
|
|
'description',
|
|
|
|
|
'status',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
protected $casts = [
|
|
|
|
|
'status' => 'integer',
|
|
|
|
|
'created_at' => 'datetime',
|
|
|
|
|
'updated_at' => 'datetime',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 关联审批节点
|
|
|
|
|
*/
|
|
|
|
|
public function nodes()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(ApprovalNode::class, 'flow_id')->orderBy('order');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取启用的流程
|
|
|
|
|
*/
|
|
|
|
|
public function scopeActive($query)
|
|
|
|
|
{
|
|
|
|
|
return $query->where('status', 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据业务类型获取流程
|
|
|
|
|
*/
|
|
|
|
|
public function scopeByBusinessType($query, string $businessType)
|
|
|
|
|
{
|
|
|
|
|
return $query->where('business_type', $businessType);
|
|
|
|
|
}
|
|
|
|
|
}
|