attributes->get('qms.device'); $queues = ServiceQueue::query() ->where('organization_id', $device->organization_id) ->when($device->branch_id, fn ($q) => $q->where('branch_id', $device->branch_id)) ->where('is_active', true) ->orderBy('name') ->get(); $this->devices->recordHeartbeat($device); return view('qms.kiosk.device', compact('device', 'queues')); } public function issue(Request $request): JsonResponse { $device = $request->attributes->get('qms.device'); $this->devices->recordHeartbeat($device); $validated = $request->validate([ 'queue_id' => ['required', 'integer', 'exists:queue_service_queues,id'], 'customer_name' => ['nullable', 'string', 'max:255'], 'customer_phone' => ['nullable', 'string', 'max:50'], 'priority' => ['nullable', 'string'], ]); $queue = ServiceQueue::findOrFail($validated['queue_id']); abort_unless($queue->organization_id === $device->organization_id, 403); $ticket = $this->engine->issueTicket($queue, $device->owner_ref, [ 'customer_name' => $validated['customer_name'] ?? null, 'customer_phone' => $validated['customer_phone'] ?? null, 'priority' => $validated['priority'] ?? 'walk_in', 'source' => 'kiosk', ]); return response()->json(['data' => TicketPresenter::toArray($ticket)]); } }