Add self-service kiosk for queue ticket issuance.
Deploy Ladill Queue / deploy (push) Successful in 36s
Deploy Ladill Queue / deploy (push) Successful in 36s
Customers can pick a service, optionally enter details, and receive a ticket on a branded touchscreen flow with admin-configurable queues and auto-reset. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Qms;
|
||||
|
||||
use App\Models\Device;
|
||||
use App\Models\ServiceQueue;
|
||||
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->config ?? [];
|
||||
|
||||
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,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Queue IDs configured on the device (empty = all branch queues).
|
||||
*
|
||||
* @return list<int>
|
||||
*/
|
||||
public function assignedQueueIds(Device $device): array
|
||||
{
|
||||
return $this->settings($device)['service_queue_ids'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, ServiceQueue>
|
||||
*/
|
||||
public function queuesFor(Device $device): Collection
|
||||
{
|
||||
$ids = $this->assignedQueueIds($device);
|
||||
|
||||
$query = ServiceQueue::query()
|
||||
->where('organization_id', $device->organization_id)
|
||||
->where('is_active', true)
|
||||
->where('is_paused', false)
|
||||
->when($device->branch_id, fn ($q) => $q->where('branch_id', $device->branch_id))
|
||||
->when($ids !== [], fn ($q) => $q->whereIn('id', $ids))
|
||||
->orderBy('name');
|
||||
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
public function queueAllowedForIssue(Device $device, int $queueId): bool
|
||||
{
|
||||
$ids = $this->assignedQueueIds($device);
|
||||
|
||||
$query = ServiceQueue::query()
|
||||
->where('organization_id', $device->organization_id)
|
||||
->where('id', $queueId)
|
||||
->when($device->branch_id, fn ($q) => $q->where('branch_id', $device->branch_id))
|
||||
->when($ids !== [], fn ($q) => $q->whereIn('id', $ids));
|
||||
|
||||
return $query->exists();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user