new helpdesk module
This commit is contained in:
@@ -16,6 +16,7 @@ final class TicketService
|
||||
private readonly TicketReferenceService $references,
|
||||
private readonly AgentAssignmentService $assignment,
|
||||
private readonly AttachmentService $attachments,
|
||||
private readonly WorkflowNotificationService $workflow,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -51,7 +52,10 @@ final class TicketService
|
||||
|
||||
$this->attachments->storeMany($ticket, $files, (int) $user->id);
|
||||
|
||||
return $ticket->fresh(['owner', 'agent', 'status', 'priority', 'category', 'project', 'team', 'attachments']) ?? $ticket;
|
||||
$ticket = $ticket->fresh(['owner', 'agent', 'status', 'priority', 'category', 'project', 'team', 'attachments']) ?? $ticket;
|
||||
$this->workflow->dispatch($ticket, 'ticket.created', $user);
|
||||
|
||||
return $ticket;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -65,12 +69,12 @@ final class TicketService
|
||||
* @param array<int, \Illuminate\Http\UploadedFile> $files
|
||||
* @return Comment
|
||||
*/
|
||||
public function comment(Ticket $ticket, User $user, string $body, bool $internal = false, array $files = []): Comment
|
||||
public function comment(Ticket $ticket, User $user, string $body, bool $internal = false, array $files = [], ?int $parentId = null): Comment
|
||||
{
|
||||
return DB::transaction(function () use ($ticket, $user, $body, $internal, $files): Comment {
|
||||
return DB::transaction(function () use ($ticket, $user, $body, $internal, $files, $parentId): Comment {
|
||||
/** @var Comment $comment */
|
||||
$comment = $ticket->comments()->create([
|
||||
'company_id' => $data['company_id'] ?? ($user->company_id ?? null),
|
||||
'parent_id' => $parentId,
|
||||
'user_id' => $user->id,
|
||||
'body' => $body,
|
||||
'is_internal' => $internal,
|
||||
@@ -78,6 +82,7 @@ final class TicketService
|
||||
|
||||
$ticket->forceFill(['last_activity_at' => now()])->save();
|
||||
$this->attachments->storeMany($ticket, $files, (int) $user->id, $comment);
|
||||
$this->workflow->dispatch($ticket->fresh(['owner', 'agent', 'status', 'priority', 'category', 'project', 'team']) ?? $ticket, $parentId === null ? 'ticket.commented' : 'ticket.reply_created', $user);
|
||||
|
||||
return $comment->fresh(['user', 'attachments']) ?? $comment;
|
||||
});
|
||||
@@ -100,6 +105,9 @@ final class TicketService
|
||||
'last_activity_at' => now(),
|
||||
])->save();
|
||||
|
||||
return $ticket->fresh(['status']) ?? $ticket;
|
||||
$ticket = $ticket->fresh(['owner', 'agent', 'status', 'priority', 'category', 'project', 'team']) ?? $ticket;
|
||||
$this->workflow->dispatch($ticket, 'ticket.closed', $user);
|
||||
|
||||
return $ticket;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user