改进 标记为 已读
This commit is contained in:
parent
fbc1c0c410
commit
3f9841559d
@ -44,6 +44,8 @@ public function show(WorkOrder $workOrder): JsonResponse
|
|||||||
{
|
{
|
||||||
$workOrder->load(['module', 'host']);
|
$workOrder->load(['module', 'host']);
|
||||||
|
|
||||||
|
$workOrder->markAsRead();
|
||||||
|
|
||||||
return $this->success($workOrder);
|
return $this->success($workOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,11 +136,33 @@ public function isClosed(): bool
|
|||||||
return $this->status === 'closed';
|
return $this->status === 'closed';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isWaitingForResponse(): bool
|
||||||
|
{
|
||||||
|
return $this->status === 'replied' || $this->status === 'user_replied';
|
||||||
|
}
|
||||||
|
|
||||||
public function isPlatform(): bool
|
public function isPlatform(): bool
|
||||||
{
|
{
|
||||||
return $this->module_id === null && $this->host_id === null;
|
return $this->module_id === null && $this->host_id === null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function markAsRead(): bool
|
||||||
|
{
|
||||||
|
if (! $this->isWaitingForResponse()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (auth('admin')) {
|
||||||
|
$this->status = 'read';
|
||||||
|
} else {
|
||||||
|
$this->status = 'user_read';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->save();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws CommonException
|
* @throws CommonException
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user