attributes->get('care.device'); $device->loadMissing('organization'); $queues = $this->kiosk->queuesFor($device); $settings = $this->kiosk->settings($device); $organization = $device->organization; $token = $this->devices->publicAccessToken($device) ?? (string) $request->route('token'); $this->devices->recordHeartbeat($device); return view('care.kiosk.device', [ 'device' => $device, 'organization' => $organization, 'queues' => $queues, 'settings' => $settings, 'kioskToken' => $token, 'logoUrl' => $organization ? OrganizationBranding::logoUrl($organization) : asset(OrganizationBranding::DEFAULT_LOGO), 'logoAlt' => $organization ? OrganizationBranding::logoAlt($organization) : 'Ladill Care', ]); } public function issue(Request $request): JsonResponse { $device = $request->attributes->get('care.device'); $this->devices->recordHeartbeat($device); $validated = $request->validate([ 'queue_id' => ['required', 'integer', 'exists:care_service_queues,id'], 'customer_name' => ['nullable', 'string', 'max:255'], 'customer_phone' => ['nullable', 'string', 'max:50'], 'priority' => ['nullable', 'string', 'max:50'], ]); abort_unless($this->kiosk->queueAllowedForIssue($device, (int) $validated['queue_id']), 403); $queue = CareServiceQueue::query()->findOrFail($validated['queue_id']); abort_unless($queue->is_active, 422, 'This queue is not accepting tickets right now.'); $ticket = $this->engine->issueTicket($device->organization, [ 'service_queue_id' => $queue->uuid, 'customer_name' => $validated['customer_name'] ?? null, 'customer_phone' => $validated['customer_phone'] ?? null, 'priority' => $validated['priority'] ?? 'walk_in', 'source' => 'kiosk', 'metadata' => [ 'device_id' => $device->id, 'device_name' => $device->name, ], ]); $ticket['queue'] = [ 'uuid' => $queue->uuid, 'name' => $queue->name, 'prefix' => $queue->prefix, ]; return response()->json(['data' => $ticket]); } }