major ui updates
This commit is contained in:
@@ -13,9 +13,6 @@ final class AgentAssignmentService
|
||||
{
|
||||
/**
|
||||
* Select the least-loaded available agent for a category.
|
||||
*
|
||||
* @param int|null $categoryId
|
||||
* @return int|null
|
||||
*/
|
||||
public function selectAgentId(?int $categoryId): ?int
|
||||
{
|
||||
|
||||
@@ -15,17 +15,13 @@ final class AttachmentService
|
||||
/**
|
||||
* Store uploaded files against a ticket and optional comment.
|
||||
*
|
||||
* @param Ticket $ticket
|
||||
* @param array<int, UploadedFile> $files
|
||||
* @param int $userId
|
||||
* @param Comment|null $comment
|
||||
* @return void
|
||||
* @param array<int, UploadedFile> $files
|
||||
*/
|
||||
public function storeMany(Ticket $ticket, array $files, int $userId, ?Comment $comment = null): void
|
||||
{
|
||||
foreach ($files as $file) {
|
||||
$disk = (string) config('helpdesk.disk');
|
||||
$path = $file->store('tickets/' . $ticket->id, $disk);
|
||||
$path = $file->store('tickets/'.$ticket->id, $disk);
|
||||
|
||||
Attachment::query()->create([
|
||||
'ticket_id' => $ticket->id,
|
||||
@@ -42,9 +38,6 @@ final class AttachmentService
|
||||
|
||||
/**
|
||||
* Delete a stored attachment and its backing file.
|
||||
*
|
||||
* @param Attachment $attachment
|
||||
* @return void
|
||||
*/
|
||||
public function delete(Attachment $attachment): void
|
||||
{
|
||||
|
||||
@@ -10,20 +10,18 @@ final class TicketReferenceService
|
||||
{
|
||||
/**
|
||||
* Build the next human-readable ticket reference.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function next(): string
|
||||
{
|
||||
$year = now()->format('Y');
|
||||
$prefix = 'HD-' . $year . '-';
|
||||
$prefix = 'HD-'.$year.'-';
|
||||
$last = Ticket::query()
|
||||
->where('reference', 'like', $prefix . '%')
|
||||
->where('reference', 'like', $prefix.'%')
|
||||
->latest('id')
|
||||
->value('reference');
|
||||
|
||||
$next = $last ? ((int) substr((string) $last, -5)) + 1 : 1;
|
||||
|
||||
return $prefix . str_pad((string) $next, 5, '0', STR_PAD_LEFT);
|
||||
return $prefix.str_pad((string) $next, 5, '0', STR_PAD_LEFT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,19 +29,17 @@ final class TicketService
|
||||
public function create(User $user, array $data, array $files = []): Ticket
|
||||
{
|
||||
return DB::transaction(function () use ($user, $data, $files): Ticket {
|
||||
$status = Status::query()
|
||||
->where('slug', config('helpdesk.default_status_slug', 'new'))
|
||||
->first();
|
||||
$defaultStatusSlug = (string) config('helpdesk.default_status_slug', 'new');
|
||||
$status = Status::query()->where('slug', $defaultStatusSlug)->first();
|
||||
|
||||
if (! $status) {
|
||||
$status = Status::query()->create([
|
||||
'name' => 'New',
|
||||
'slug' => config('helpdesk.default_status_slug', 'new'),
|
||||
'slug' => $defaultStatusSlug,
|
||||
'color' => 'sky',
|
||||
'sort_order' => 5,
|
||||
'sort_order' => 1,
|
||||
'is_closed' => false,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
/** @var Ticket $ticket */
|
||||
|
||||
@@ -16,11 +16,6 @@ final class WorkflowNotificationService
|
||||
{
|
||||
/**
|
||||
* Send all active workflow messages for the supplied ticket event.
|
||||
*
|
||||
* @param Ticket $ticket
|
||||
* @param string $event
|
||||
* @param User|null $actor
|
||||
* @return void
|
||||
*/
|
||||
public function dispatch(Ticket $ticket, string $event, ?User $actor = null): void
|
||||
{
|
||||
@@ -35,6 +30,7 @@ final class WorkflowNotificationService
|
||||
|
||||
if ($recipient === null || blank($recipient->email ?? null)) {
|
||||
$this->log($template, $ticket, $event, null, 'skipped', 'No recipient email was available.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -63,7 +59,6 @@ final class WorkflowNotificationService
|
||||
});
|
||||
}
|
||||
|
||||
/** @return User|null */
|
||||
private function recipient(string $role, Ticket $ticket, ?User $actor): ?User
|
||||
{
|
||||
return match ($role) {
|
||||
@@ -95,15 +90,15 @@ final class WorkflowNotificationService
|
||||
private function wrapHtml(string $body, Ticket $ticket): string
|
||||
{
|
||||
return '<div style="font-family:Inter,Arial,sans-serif;background:#f6f8fb;padding:24px">'
|
||||
. '<div style="max-width:720px;margin:0 auto;background:#ffffff;border:1px solid #d8dee8;border-radius:18px;overflow:hidden">'
|
||||
. '<div style="background:#0f172a;color:#ffffff;padding:24px 28px">'
|
||||
. '<div style="font-size:12px;letter-spacing:.18em;text-transform:uppercase;color:#bfdbfe">Helpdesk notification</div>'
|
||||
. '<h1 style="margin:8px 0 0;font-size:22px">' . e($ticket->reference) . '</h1>'
|
||||
. '<p style="margin:8px 0 0;color:#dbeafe">' . e($ticket->subject) . '</p>'
|
||||
. '</div><div style="padding:28px;color:#1f2937;line-height:1.65">'
|
||||
. $body
|
||||
. '<p style="margin-top:28px"><a href="' . e(route('helpdesk.tickets.show', ['ticket' => $ticket->getKey()])) . '" style="display:inline-block;background:#2563eb;color:#ffffff;text-decoration:none;padding:11px 16px;border-radius:10px">Open ticket</a></p>'
|
||||
. '</div></div></div>';
|
||||
.'<div style="max-width:720px;margin:0 auto;background:#ffffff;border:1px solid #d8dee8;border-radius:18px;overflow:hidden">'
|
||||
.'<div style="background:#0f172a;color:#ffffff;padding:24px 28px">'
|
||||
.'<div style="font-size:12px;letter-spacing:.18em;text-transform:uppercase;color:#bfdbfe">Helpdesk notification</div>'
|
||||
.'<h1 style="margin:8px 0 0;font-size:22px">'.e($ticket->reference).'</h1>'
|
||||
.'<p style="margin:8px 0 0;color:#dbeafe">'.e($ticket->subject).'</p>'
|
||||
.'</div><div style="padding:28px;color:#1f2937;line-height:1.65">'
|
||||
.$body
|
||||
.'<p style="margin-top:28px"><a href="'.e(route('helpdesk.tickets.show', ['ticket' => $ticket->getKey()])).'" style="display:inline-block;background:#2563eb;color:#ffffff;text-decoration:none;padding:11px 16px;border-radius:10px">Open ticket</a></p>'
|
||||
.'</div></div></div>';
|
||||
}
|
||||
|
||||
private function log(WorkflowTemplate $template, Ticket $ticket, string $event, ?string $recipient, string $status, ?string $error = null, ?string $subject = null): void
|
||||
|
||||
Reference in New Issue
Block a user