改进 访客权限
This commit is contained in:
parent
5b83872bac
commit
50fd2edd81
@ -41,6 +41,11 @@ public function store(Request $request, WorkOrder $workOrder)
|
|||||||
return $this->error('工单状态异常,无法进行回复。请尝试重新建立工单。');
|
return $this->error('工单状态异常,无法进行回复。请尝试重新建立工单。');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 如果工单已经关闭,那么访客不能回复
|
||||||
|
if ($workOrder->isClosed() && !auth('sanctum')->check()) {
|
||||||
|
return $this->error('工单已关闭,无法进行回复。');
|
||||||
|
}
|
||||||
|
|
||||||
$create = [
|
$create = [
|
||||||
'content' => $request->input('content'),
|
'content' => $request->input('content'),
|
||||||
'work_order_id' => $workOrder->id,
|
'work_order_id' => $workOrder->id,
|
||||||
|
@ -66,6 +66,11 @@ public function update(Request $request, WorkOrder $workOrder)
|
|||||||
'status' => 'nullable|sometimes|string|in:closed',
|
'status' => 'nullable|sometimes|string|in:closed',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// 访客不能关闭
|
||||||
|
if ($request->input('status') === 'closed' && !auth('sanctum')->check()) {
|
||||||
|
return $this->error('访客不能修改工单状态。');
|
||||||
|
}
|
||||||
|
|
||||||
$workOrder->update($request->only('status'));
|
$workOrder->update($request->only('status'));
|
||||||
|
|
||||||
return $this->success($workOrder);
|
return $this->success($workOrder);
|
||||||
|
@ -164,6 +164,16 @@ public function isFailure(): bool
|
|||||||
return $this->status === 'pending' || $this->status === 'error';
|
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
|
* @throws CommonException
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user