main
panliang 2024-04-26 10:03:04 +08:00
parent 4ce6d2db9a
commit 82930c1cf5
1 changed files with 10 additions and 2 deletions

View File

@ -39,7 +39,7 @@ class WorkflowController extends Controller
$query = $model::query()->with($include) $query = $model::query()->with($include)
// ->whereHas('workflow', fn($q) => $q->where('check_status', CheckStatus::Processing)) // ->whereHas('workflow', fn($q) => $q->where('check_status', CheckStatus::Processing))
->whereHas('workflow.logs', fn($q) => $q->own($user)) ->whereHas('workflow.logs', fn($q) => $q->own($user)->where('check_status', '>', CheckStatus::None->value))
->orderBy('created_at', 'desc'); ->orderBy('created_at', 'desc');
$list = $query->paginate($request->input('per_page')); $list = $query->paginate($request->input('per_page'));
@ -66,8 +66,12 @@ class WorkflowController extends Controller
$subjectType = $request->input('subject_type'); $subjectType = $request->input('subject_type');
$model = Relation::getMorphedModel($subjectType); $model = Relation::getMorphedModel($subjectType);
$resource = $this->mapResource($model); $resource = $this->mapResource($model);
// 当前用户是否可以审核
$checkable = false;
$include = ['workflow']; $include = ['workflow'];
if ($request->input('include')) { if ($request->input('include')) {
$explodes = explode(',', $request->input('include')); $explodes = explode(',', $request->input('include'));
@ -85,14 +89,18 @@ class WorkflowController extends Controller
}, },
])->findOrFail($id); ])->findOrFail($id);
$info->taskable->setRelation('task', $info->withoutRelations()); $info->taskable->setRelation('task', $info->withoutRelations());
$checkable = $info->taskable->workflow->logs()->own($user)->where('check_status', CheckStatus::Processing)->exists();
break; break;
default: default:
$info = $model::query()->with($include)->findOrFail($id); $info = $model::query()->with($include)->findOrFail($id);
$checkable = $info->workflow->logs()->own($user)->where('check_status', CheckStatus::Processing)->exists();
break; break;
} }
return $resource::make($info); $data = $resource::make($info)->toArray($request);
$data['checkable'] = $checkable;
return $data;
} }
public function logs($id, Request $request) public function logs($id, Request $request)