proper closer status

This commit is contained in:
Mark Gregory
2026-06-23 11:01:55 +01:00
parent e12ab543e8
commit a6148f9bfd
8 changed files with 329 additions and 50 deletions
+31 -1
View File
@@ -54,6 +54,10 @@ final class TicketShow extends Component
public ?int $agent_id = null;
public string $closureComment = '';
public bool $closureInternal = false;
public ?int $reply_parent_id = null;
public string $replyBody = '';
@@ -144,7 +148,7 @@ final class TicketShow extends Component
$this->ticket = $this->freshTicket($this->ticket);
}
public function updateStatus(WorkflowNotificationService $workflow, SlaService $sla): void
public function updateStatus(WorkflowNotificationService $workflow, SlaService $sla, TicketService $tickets): void
{
$this->authorize('update', $this->ticket);
@@ -157,6 +161,17 @@ final class TicketShow extends Component
$status = Status::query()->findOrFail($statusId);
if ($status->is_closed) {
validator([
'closureComment' => $this->closureComment,
], [
'closureComment' => ['required', 'string', 'min:10', 'max:5000'],
], [
'closureComment.required' => 'A closure comment is required before closing the ticket.',
'closureComment.min' => 'The closure comment must explain why the ticket is being closed.',
])->validate();
}
$updates = [
'status_id' => $status->id,
'completed_at' => $status->is_closed ? now() : null,
@@ -175,6 +190,21 @@ final class TicketShow extends Component
$this->status_id = (int) $this->ticket->status_id;
if ($status->is_closed) {
$user = Auth::user();
abort_if($user === null, 403);
$tickets->comment(
$this->ticket,
$user,
trim($this->closureComment),
$this->closureInternal,
[],
null,
'Closure comment'
);
$this->reset(['closureComment', 'closureInternal']);
$this->ticket = $this->freshTicket($this->ticket);
$sla->recordClosure($this->ticket);
}