query->get('from', ''); $toRaw = (string) $request->query->get('to', ''); if ('' === $fromRaw || '' === $toRaw) { throw new UnprocessableEntityHttpException('Query parameters "from" and "to" are required.'); } $from = new DateTimeImmutable($fromRaw); $to = new DateTimeImmutable($toRaw); $absences = $this->requestRepository->findInRange($from, $to); return $this->json($absences, context: ['groups' => ['absence_request:read']]); } }