Add queue kiosk and display devices for Care Queue management.
Deploy Ladill Care / deploy (push) Successful in 39s

Register walk-up kiosks and waiting-room display devices under Devices, with public kiosk ticket issue and linked TV boards surfaced in sidebar and Queue shortcuts.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-20 10:59:02 +00:00
co-authored by Cursor
parent b2cebe2908
commit a3839da869
18 changed files with 1103 additions and 60 deletions
+41 -2
View File
@@ -33,14 +33,28 @@ class DeviceService
public function issueToken(Device $device): string
{
$plain = $this->generateToken();
$device->update(['device_token_hash' => $this->hashToken($plain)]);
$meta = $device->metadata ?? [];
if ($this->isQueueDeviceType($device->type)) {
$meta['access_token'] = $plain;
}
$device->update([
'device_token_hash' => $this->hashToken($plain),
'metadata' => $meta,
]);
return $plain;
}
public function revokeToken(Device $device): Device
{
$device->update(['device_token_hash' => null]);
$meta = $device->metadata ?? [];
unset($meta['access_token']);
$device->update([
'device_token_hash' => null,
'metadata' => $meta,
]);
return $device->fresh();
}
@@ -66,6 +80,7 @@ class DeviceService
public function defaultConnectionMode(string $type): string
{
return match ($type) {
'kiosk', 'display' => Device::MODE_MANUAL,
'barcode_scanner', 'qr_scanner' => Device::MODE_BROWSER_WEDGE,
'badge_printer' => Device::MODE_MANUAL,
'thermometer', 'bp_monitor', 'pulse_ox', 'weight_scale', 'lab_analyzer', 'agent' => Device::MODE_AGENT,
@@ -73,6 +88,11 @@ class DeviceService
};
}
public function isQueueDeviceType(string $type): bool
{
return in_array($type, config('care.queue_device_types', []), true);
}
public function typeRequiresPro(string $type): bool
{
return in_array($type, config('care.device_agent_types', []), true);
@@ -80,6 +100,10 @@ class DeviceService
public function canRegisterType(Organization $organization, string $type, PlanService $plans): bool
{
if ($this->isQueueDeviceType($type)) {
return $plans->hasPaidPlan($organization);
}
if (! $this->typeRequiresPro($type)) {
return true;
}
@@ -87,8 +111,23 @@ class DeviceService
return $plans->hasPaidPlan($organization);
}
public function publicAccessToken(Device $device): ?string
{
$token = $device->metadata['access_token'] ?? null;
return is_string($token) && $token !== '' ? $token : null;
}
public function connectionHint(string $type, string $mode): string
{
if ($type === 'kiosk') {
return 'Walk-up ticket kiosk. Open the public kiosk URL on a tablet in kiosk mode.';
}
if ($type === 'display') {
return 'Waiting-room / counter display. Opens the linked TV board URL on a screen or tablet.';
}
return match ($mode) {
Device::MODE_BROWSER_WEDGE => 'Works in the browser today as a USB keyboard wedge (scan into the focused field). No local agent required.',
Device::MODE_AGENT => 'Needs the Care Device Agent on a local machine (serial / BLE / vendor SDK). Browser alone cannot talk to this hardware.',
+90
View File
@@ -0,0 +1,90 @@
<?php
namespace App\Services\Care;
use App\Models\CareServiceQueue;
use App\Models\Device;
use Illuminate\Support\Collection;
class KioskService
{
/**
* @return array{service_queue_ids: list<int>, collect_name: bool, collect_phone: bool, reset_seconds: int, welcome_message: ?string}
*/
public function settings(Device $device): array
{
$config = $device->metadata ?? [];
return [
'service_queue_ids' => array_values(array_filter(array_map(
'intval',
$config['service_queue_ids'] ?? [],
))),
'collect_name' => (bool) ($config['collect_name'] ?? false),
'collect_phone' => (bool) ($config['collect_phone'] ?? false),
'reset_seconds' => max(5, (int) ($config['reset_seconds'] ?? 15)),
'welcome_message' => filled($config['welcome_message'] ?? null)
? (string) $config['welcome_message']
: null,
];
}
/**
* @return list<int>
*/
public function assignedQueueIds(Device $device): array
{
return $this->settings($device)['service_queue_ids'];
}
/**
* @return Collection<int, CareServiceQueue>
*/
public function queuesFor(Device $device): Collection
{
$ids = $this->assignedQueueIds($device);
return CareServiceQueue::query()
->where('organization_id', $device->organization_id)
->where('is_active', true)
->when($device->branch_id, fn ($q) => $q->where('branch_id', $device->branch_id))
->when($ids !== [], fn ($q) => $q->whereIn('id', $ids))
->orderBy('name')
->get();
}
public function queueAllowedForIssue(Device $device, int $queueId): bool
{
$ids = $this->assignedQueueIds($device);
return CareServiceQueue::query()
->where('organization_id', $device->organization_id)
->where('id', $queueId)
->where('is_active', true)
->when($device->branch_id, fn ($q) => $q->where('branch_id', $device->branch_id))
->when($ids !== [], fn ($q) => $q->whereIn('id', $ids))
->exists();
}
/**
* @param array<string, mixed> $input
* @return array<string, mixed>
*/
public function buildMetadata(array $input, array $allowedQueueIds = []): array
{
$queueIds = array_values(array_intersect(
array_map('intval', $input['queue_ids'] ?? []),
$allowedQueueIds,
));
return [
'service_queue_ids' => $queueIds,
'collect_name' => (bool) ($input['collect_name'] ?? false),
'collect_phone' => (bool) ($input['collect_phone'] ?? false),
'reset_seconds' => max(5, min(120, (int) ($input['reset_seconds'] ?? 15))),
'welcome_message' => filled($input['welcome_message'] ?? null)
? (string) $input['welcome_message']
: null,
];
}
}