findBy(['person' => $person], ['startDate' => 'DESC']); $date = null === $at ? new DateTimeImmutable('today') : $at; foreach ($addresses as $a) { if($a->getStartDate() < $date && $a->getEndDate() > $date) { return $a; } } return null; } // /** // * @return ResidentialAddress[] Returns an array of ResidentialAddress objects // */ /* public function findByExampleField($value) { return $this->createQueryBuilder('r') ->andWhere('r.exampleField = :val') ->setParameter('val', $value) ->orderBy('r.id', 'ASC') ->setMaxResults(10) ->getQuery() ->getResult() ; } */ /* public function findOneBySomeField($value): ?ResidentialAddress { return $this->createQueryBuilder('r') ->andWhere('r.exampleField = :val') ->setParameter('val', $value) ->getQuery() ->getOneOrNullResult() ; } */ }