@php $role = session('login_role'); $rolePath = $role === 'staff' ? 'staff' : 'student'; $portal = $role === 'staff' ? 'STAFF PORTAL' : 'STUDENT PORTAL'; $queuesByRoom = []; foreach ($rooms ?? [] as $room) { $queuesByRoom[$room['id']] = [ 'room' => $room, 'appointments' => [], ]; } foreach ($appointments ?? [] as $appt) { if (isset($queuesByRoom[$appt['room_id']])) { $queuesByRoom[$appt['room_id']]['appointments'][] = $appt; } } $myQueue = $myAppointment['queue_number'] ?? '-'; $myRoomId = $myAppointment['room_id'] ?? null; $nowServing = '-'; $waitingBefore = 0; $myRoomName = 'No appointment today'; if ($myRoomId && isset($queuesByRoom[$myRoomId])) { $roomQueue = $queuesByRoom[$myRoomId]['appointments']; $nowServing = $roomQueue[0]['queue_number'] ?? '-'; $myRoomName = $queuesByRoom[$myRoomId]['room']['room_name'] ?? 'Room assigned'; foreach ($roomQueue as $index => $appt) { if (($appt['id'] ?? '') === ($myAppointment['id'] ?? '')) { $waitingBefore = $index; break; } } } $estWait = $waitingBefore * 15; @endphp Live Queue - PKU Dental

Live Queue — Real-Time Tracking

{{ now()->format('D, d M Y') }}

Live Queue Status

Last updated: {{ now()->format('h:i A') }}

YOUR QUEUE NUMBER
{{ $myQueue }}
{{ $myRoomName }}
Now Serving
{{ $nowServing }}
Current queue
Waiting
{{ $waitingBefore }}
Before you
Est. Wait
~{{ $estWait }} min
Approx
@foreach($queuesByRoom as $roomData) @php $room = $roomData['room']; $roomAppointments = $roomData['appointments']; @endphp

{{ $room['room_name'] ?? 'Room' }}

{{ $room['patient_category'] ?? 'Dental Queue' }}

@if(count($roomAppointments) > 0) @foreach($roomAppointments as $index => $appt) @php $isMine = ($myAppointment && $appt['id'] === $myAppointment['id']); $isServing = $index === 0; @endphp
{{ $appt['queue_number'] ?? '-' }} @if($isServing) Serving @endif @if($isMine) You @endif
@endforeach @else
No queue for today.
@endif
@endforeach