validate([ 'month' => 'nullable|date_format:Y-m', ]); $holidays = isset($data['month']) ? $this->capacityService->getHolidaysForMonth($data['month']) : Holiday::orderBy('date')->get(); return response()->json($holidays); } /** * Create Holiday * * Add a holiday and clear cached capacity data for the related month. * * @group Capacity Planning * @bodyParam date string required Date of the holiday. Example: 2026-02-14 * @bodyParam name string required Name of the holiday. Example: Presidents' Day * @bodyParam description string nullable Optional description of the holiday. * @response 201 { * "id": "550e8400-e29b-41d4-a716-446655440000", * "date": "2026-02-14", * "name": "Presidents' Day", * "description": "Office closed" * } */ public function store(Request $request): JsonResponse { $data = $request->validate([ 'date' => 'required|date', 'name' => 'required|string', 'description' => 'nullable|string', ]); $holiday = Holiday::create($data); $this->capacityService->forgetCapacityCacheForMonth($holiday->date->format('Y-m')); return response()->json($holiday, 201); } /** * Delete Holiday * * Remove a holiday and clear affected capacity caches. * * @group Capacity Planning * @urlParam id string required The holiday UUID. Example: 550e8400-e29b-41d4-a716-446655440000 * @response { * "message": "Holiday deleted" * } */ public function destroy(string $id): JsonResponse { $holiday = Holiday::find($id); if (! $holiday) { return response()->json(['message' => 'Holiday not found'], 404); } $month = $holiday->date->format('Y-m'); $holiday->delete(); $this->capacityService->forgetCapacityCacheForMonth($month); return response()->json(['message' => 'Holiday deleted']); } }