new helpdesk module

This commit is contained in:
Mark Gregory
2026-06-12 09:41:57 +01:00
parent 67c9bb22d9
commit da35c7eb95
50 changed files with 1874 additions and 270 deletions
@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace Modules\Helpdesk\Services;
use Modules\Helpdesk\Models\Ticket;
final class TicketReferenceService
{
/**
* Build the next human-readable ticket reference.
*
* @return string
*/
public function next(): string
{
$year = now()->format('Y');
$prefix = 'HD-' . $year . '-';
$last = Ticket::query()
->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);
}
}