copy()->startOfWeek(\Carbon\Carbon::MONDAY); $fridayCutoff = $start->copy()->addDays(4)->setTime(15, 0); if ($now->greaterThanOrEqualTo($fridayCutoff)) { $start->addWeek(); } // Week navigation $weekOffset = (int) $request->query('week', 0); if ($weekOffset !== 0) { $start->addWeeks($weekOffset); } $end = $start->copy()->addDays(6); // 👉 Load slots with bookings for the visible week $slots = \App\Models\Slot::with(['bookings' => function ($q) use ($start, $end) { $q->whereBetween('date', [$start->toDateString(), $end->toDateString()]); }])->get(); // 👉 Pass $slots (and the other vars) to the view return view('calendar.index', compact('start', 'end', 'weekOffset', 'slots', 'now')); } }