改进 访客权限

This commit is contained in:
iVampireSP.com 2023-01-02 18:52:38 +08:00
parent 5b83872bac
commit 50fd2edd81
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132
3 changed files with 20 additions and 0 deletions

View File

@ -41,6 +41,11 @@ public function store(Request $request, WorkOrder $workOrder)
return $this->error('工单状态异常,无法进行回复。请尝试重新建立工单。');
}
// 如果工单已经关闭,那么访客不能回复
if ($workOrder->isClosed() && !auth('sanctum')->check()) {
return $this->error('工单已关闭,无法进行回复。');
}
$create = [
'content' => $request->input('content'),
'work_order_id' => $workOrder->id,

View File

@ -66,6 +66,11 @@ public function update(Request $request, WorkOrder $workOrder)
'status' => 'nullable|sometimes|string|in:closed',
]);
// 访客不能关闭
if ($request->input('status') === 'closed' && !auth('sanctum')->check()) {
return $this->error('访客不能修改工单状态。');
}
$workOrder->update($request->only('status'));
return $this->success($workOrder);

View File

@ -164,6 +164,16 @@ public function isFailure(): bool
return $this->status === 'pending' || $this->status === 'error';
}
public function isOpen(): bool
{
return $this->status !== 'closed' && $this->status !== 'error' && $this->status !== 'pending';
}
public function isClosed(): bool
{
return $this->status === 'closed';
}
/**
* @throws CommonException
*/