@endif
@if(!empty($reservedSlots))
@php
// التأكد من شكل الـ array إذا كانت Grouped by clinic or not
$isGroupedByClinic = false;
$first = collect($reservedSlots)->first();
if (is_array($first)) {
$firstInner = reset($first); // نحاول نجيب أول عنصر داخلي
$isGroupedByClinic = is_array($firstInner) && isset($firstInner[0]['time']);
}
@endphp
Appointments
@if($isGroupedByClinic)
{{-- ✅ Grouped by Clinic → Date --}}
@foreach($reservedSlots as $clinic => $dates)
{{ $clinic }}
@foreach($dates as $date => $slots)
{{ \Carbon\Carbon::parse($date)->translatedFormat('l, d M Y') }}
@foreach($slots as $slot)
@if(is_array($slot) && isset($slot['time'], $slot['patient']))