Files
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

119 lines
2.8 KiB
PHP

<?php
namespace App\Services\Qms\Industry;
/**
* Read-only view of a configured industry package.
*
* @phpstan-type StageDef array{
* code: string,
* department: string,
* name: string,
* prefix: string,
* strategy?: string,
* routing_mode?: string,
* routing_strategy?: string,
* optional?: bool,
* service_points?: list<array{name: string, destination?: string, code?: string}>
* }
*/
class IndustryPackage
{
/**
* @param array<string, mixed> $definition
*/
public function __construct(
public readonly string $key,
public readonly array $definition,
) {}
public function label(): string
{
return (string) ($this->definition['label'] ?? $this->key);
}
public function description(): string
{
return (string) ($this->definition['description'] ?? '');
}
public function ticketEntity(): string
{
return (string) ($this->definition['ticket_entity'] ?? 'customer');
}
public function displayLayout(): string
{
return (string) ($this->definition['display_layout'] ?? 'standard');
}
/**
* @return array<string, string>
*/
public function terminology(): array
{
return (array) ($this->definition['terminology'] ?? []);
}
/**
* Priority keys stay global; labels are industry-specific.
*
* @return array<string, string>
*/
public function priorities(): array
{
$fromPackage = (array) ($this->definition['priorities'] ?? []);
$fromIndustry = (array) config("qms.ticket_priorities_by_industry.{$this->key}", []);
return \App\Services\Qms\TicketPriorities::mergeDefaults(array_merge($fromIndustry, $fromPackage));
}
/**
* @return array<string, string>
*/
public function announcement(): array
{
return (array) ($this->definition['announcement'] ?? []);
}
/**
* @return list<string>
*/
public function kpis(): array
{
return array_values((array) ($this->definition['kpis'] ?? []));
}
/**
* @return array{name: string, description?: string}
*/
public function workflowMeta(): array
{
return (array) ($this->definition['workflow'] ?? ['name' => $this->label().' workflow']);
}
/**
* @return list<array{code: string, name: string, type: string}>
*/
public function departments(): array
{
return array_values((array) ($this->definition['departments'] ?? []));
}
/**
* @return list<StageDef>
*/
public function stages(): array
{
return array_values((array) ($this->definition['stages'] ?? []));
}
/**
* @return list<string>
*/
public function integrations(): array
{
return array_values((array) ($this->definition['integrations'] ?? []));
}
}