proper closer status
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user