style updates

This commit is contained in:
Mark Gregory
2026-06-23 13:39:02 +01:00
parent e79cadc7f8
commit 3be4ff590f
129 changed files with 482 additions and 404 deletions
@@ -26,7 +26,7 @@ final class AgentAssignmentService
->selectRaw('count(*)')
->whereColumn('helpdesk_tickets.agent_id', 'users.id')
->whereNull('helpdesk_tickets.completed_at'),
'open_helpdesk_tickets_count'
'open_helpdesk_tickets_count',
);
if ($categoryId !== null) {
@@ -24,7 +24,7 @@ final class AttachmentService
$mimeType = $file->getClientMimeType();
$size = (int) ($file->getSize() ?: 0);
$path = $file->store('tickets/'.$ticket->id, $disk);
$path = $file->store('tickets/' . $ticket->id, $disk);
if ($size === 0 && $path !== false) {
$size = (int) Storage::disk($disk)->size($path);
@@ -19,7 +19,8 @@ final class GitWebhookIngestionService
/**
* Persist supported Git provider commits and link them to matching Helpdesk ticket references.
*
* @param array<string, mixed> $payload
* @param array<string, mixed> $payload
*
* @return array{status: string, message: string, commit_count: int, linked_count: int, ignored_count: int}
*/
public function ingest(GitRepository $repository, array $payload, string $provider, ?string $deliveryId, ?string $event): array
@@ -76,7 +77,7 @@ final class GitWebhookIngestionService
'message' => $message,
'url' => $url,
'committed_at' => $committedAt,
]
],
);
$commitCount++;
@@ -102,8 +103,8 @@ final class GitWebhookIngestionService
/**
* Record a provider webhook acceptance, rejection or ignore decision for auditability.
*
* @param array{status: string, message: string, commit_count?: int, linked_count?: int, ignored_count?: int} $result
* @param array<string, mixed>|null $payload
* @param array{status: string, message: string, commit_count?: int, linked_count?: int, ignored_count?: int} $result
* @param array<string, mixed>|null $payload
*/
public function logWebhook(GitRepository $repository, string $provider, ?string $deliveryId, ?string $event, array $result, ?array $payload = null): void
{
@@ -170,7 +171,8 @@ final class GitWebhookIngestionService
}
/**
* @param array<string, mixed> $payload
* @param array<string, mixed> $payload
*
* @return array<int, array<string, mixed>>
*/
private function commitsFromPayload(array $payload): array
@@ -186,7 +188,7 @@ final class GitWebhookIngestionService
private function ticketForCommit(GitRepository $repository, string $message, ?string $branch, ?string $url): ?Ticket
{
$reference = $this->extractTicketReference(trim($message.' '.($branch ?? '').' '.($url ?? '')));
$reference = $this->extractTicketReference(trim($message . ' ' . ($branch ?? '') . ' ' . ($url ?? '')));
if ($reference === null) {
return null;
+3 -2
View File
@@ -5,8 +5,9 @@ declare(strict_types=1);
namespace Modules\Helpdesk\Services;
use App\Models\User;
use Modules\Helpdesk\Models\SlaPolicy;
use Illuminate\Support\Carbon;
use Modules\Helpdesk\Models\Comment;
use Modules\Helpdesk\Models\SlaPolicy;
use Modules\Helpdesk\Models\Ticket;
use Modules\Helpdesk\Models\TicketSlaEvent;
@@ -89,7 +90,7 @@ final class SlaService
private function markFirstResponse(Ticket $ticket, mixed $respondedAt, ?User $actor = null): void
{
$respondedAt = $respondedAt instanceof \Illuminate\Support\Carbon
$respondedAt = $respondedAt instanceof Carbon
? $respondedAt
: now();
@@ -29,7 +29,7 @@ final class TicketReferenceService
{
$year = (int) now()->format('Y');
$prefix = 'HD';
$seriesPrefix = $prefix.'-'.$year.'-';
$seriesPrefix = $prefix . '-' . $year . '-';
$this->lockReferenceSeries($seriesPrefix);
@@ -76,7 +76,7 @@ final class TicketReferenceService
'updated_at' => now(),
]);
return $seriesPrefix.str_pad((string) $nextNumber, 5, '0', STR_PAD_LEFT);
return $seriesPrefix . str_pad((string) $nextNumber, 5, '0', STR_PAD_LEFT);
}
/**
@@ -84,7 +84,7 @@ final class TicketReferenceService
*/
private function nextFromExistingReferences(string $seriesPrefix): string
{
return $seriesPrefix.str_pad((string) ($this->highestExistingSuffix($seriesPrefix) + 1), 5, '0', STR_PAD_LEFT);
return $seriesPrefix . str_pad((string) ($this->highestExistingSuffix($seriesPrefix) + 1), 5, '0', STR_PAD_LEFT);
}
/**
@@ -96,9 +96,9 @@ final class TicketReferenceService
$existingReferences = Ticket::query()
->withoutGlobalScopes()
->withTrashed()
->where('reference', 'like', $seriesPrefix.'%')
->where('reference', 'like', $seriesPrefix . '%')
->pluck('reference')
->filter(static fn (mixed $reference): bool => is_string($reference) && preg_match('/^'.preg_quote($seriesPrefix, '/').'\d+$/', $reference) === 1)
->filter(static fn (mixed $reference): bool => is_string($reference) && preg_match('/^' . preg_quote($seriesPrefix, '/') . '\d+$/', $reference) === 1)
->values()
->all();
@@ -121,7 +121,7 @@ final class TicketReferenceService
}
DB::select('select pg_advisory_xact_lock(hashtext(?))', [
'helpdesk-ticket-reference:'.$seriesPrefix,
'helpdesk-ticket-reference:' . $seriesPrefix,
]);
}
}
+8 -8
View File
@@ -5,8 +5,8 @@ declare(strict_types=1);
namespace Modules\Helpdesk\Services;
use App\Models\User;
use Illuminate\Http\UploadedFile;
use Illuminate\Database\QueryException;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
@@ -30,8 +30,8 @@ final class TicketService
/**
* Create a ticket and store initial attachments.
*
* @param array<string, mixed> $data
* @param array<int, UploadedFile> $files
* @param array<string, mixed> $data
* @param array<int, UploadedFile> $files
*/
public function create(User $user, array $data, array $files = []): Ticket
{
@@ -51,8 +51,8 @@ final class TicketService
/**
* Create the ticket while the caller owns the database transaction.
*
* @param array<string, mixed> $data
* @param array<int, UploadedFile> $files
* @param array<string, mixed> $data
* @param array<int, UploadedFile> $files
*/
private function createInsideTransaction(User $user, array $data, array $files = []): Ticket
{
@@ -132,7 +132,7 @@ final class TicketService
/**
* Add a public or internal comment and optional attachments.
*
* @param array<int, UploadedFile> $files
* @param array<int, UploadedFile> $files
*/
public function comment(Ticket $ticket, User $user, string $body, bool $internal = false, array $files = [], ?int $parentId = null, ?string $subject = null): Comment
{
@@ -144,7 +144,7 @@ final class TicketService
->findOrFail($parentId);
$guid = (string) Str::uuid();
$unid = strtoupper(hash('sha256', $guid.'|'.$ticket->id.'|'.microtime(true)));
$unid = strtoupper(hash('sha256', $guid . '|' . $ticket->id . '|' . microtime(true)));
$parentUnid = $parent?->unid;
$rootUnid = $parent?->root_unid ?: $parentUnid ?: $unid;
$plainTextBody = trim(preg_replace('/\s+/', ' ', strip_tags($body)) ?: '');
@@ -159,7 +159,7 @@ final class TicketService
'unid' => $unid,
'parent_unid' => $parentUnid,
'root_unid' => $rootUnid,
'originator_id' => $unid.':1',
'originator_id' => $unid . ':1',
'sync_sequence' => 1,
'sync_hash' => hash('sha256', $body),
'source_system' => 'wms-helpdesk',
@@ -133,16 +133,16 @@ final class WorkflowNotificationService
private function wrapHtml(string $body, Ticket $ticket, ?string $trackingToken = null): 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>'
.$this->trackingPixel($trackingToken)
.'</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>'
. $this->trackingPixel($trackingToken)
. '</div></div></div>';
}
private function trackingPixel(?string $trackingToken): string
@@ -153,9 +153,9 @@ final class WorkflowNotificationService
$url = Route::has('helpdesk.workflow.open')
? route('helpdesk.workflow.open', ['token' => $trackingToken])
: URL::to('/'.trim((string) config('helpdesk.route_prefix', 'helpdesk'), '/').'/workflow/open/'.$trackingToken);
: URL::to('/' . trim((string) config('helpdesk.route_prefix', 'helpdesk'), '/') . '/workflow/open/' . $trackingToken);
return '<img src="'.e($url).'" width="1" height="1" alt="" style="display:none" />';
return '<img src="' . e($url) . '" width="1" height="1" alt="" style="display:none" />';
}
private function log(WorkflowTemplate $template, Ticket $ticket, string $event, ?string $recipient, string $status, ?string $error = null, ?string $subject = null, ?string $trackingToken = null): void