Files
ladill-queue/app/Services/Qms/TicketPriorities.php
T
isaaccladandCursor b5ffa499b9
Deploy Ladill Queue / deploy (push) Successful in 55s
Use industry-specific ticket priority labels.
Restaurant (and other packages) now show Rush, Reservation, VIP table, etc. instead of clinic terms like Emergency and Elderly.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-17 20:15:56 +00:00

67 lines
1.8 KiB
PHP

<?php
namespace App\Services\Qms;
use App\Models\Organization;
use App\Services\Qms\Industry\IndustryPackageRegistry;
class TicketPriorities
{
/**
* @return array<string, string> priority key => industry label
*/
public static function forOrganization(?Organization $organization): array
{
$stored = data_get($organization?->settings, 'industry_package.priorities');
if (is_array($stored) && $stored !== []) {
return self::mergeDefaults($stored);
}
$key = (string) (
data_get($organization?->settings, 'industry_package.key')
?? data_get($organization?->settings, 'industry')
?? 'custom'
);
return self::forIndustryKey($key);
}
/**
* @return array<string, string>
*/
public static function forIndustryKey(string $key): array
{
$package = app(IndustryPackageRegistry::class)->get($key);
return $package?->priorities() ?? self::mergeDefaults(
(array) config("qms.ticket_priorities_by_industry.{$key}", [])
);
}
public static function label(?Organization $organization, ?string $priority): string
{
if ($priority === null || $priority === '') {
return '';
}
$map = self::forOrganization($organization);
return $map[$priority] ?? (string) (config("qms.ticket_priorities.{$priority}") ?? $priority);
}
/**
* @param array<string, string> $overrides
* @return array<string, string>
*/
public static function mergeDefaults(array $overrides): array
{
$defaults = (array) config('qms.ticket_priorities', []);
$merged = [];
foreach ($defaults as $key => $label) {
$merged[$key] = (string) ($overrides[$key] ?? $label);
}
return $merged;
}
}