改进 标记为 已读

This commit is contained in:
iVampireSP.com 2023-02-02 20:31:34 +08:00
parent fbc1c0c410
commit 3f9841559d
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132
2 changed files with 24 additions and 0 deletions

View File

@ -44,6 +44,8 @@ public function show(WorkOrder $workOrder): JsonResponse
{
$workOrder->load(['module', 'host']);
$workOrder->markAsRead();
return $this->success($workOrder);
}

View File

@ -136,11 +136,33 @@ public function isClosed(): bool
return $this->status === 'closed';
}
public function isWaitingForResponse(): bool
{
return $this->status === 'replied' || $this->status === 'user_replied';
}
public function isPlatform(): bool
{
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
*/