entityManager = $entityManager; } public function findById(int $id) { return $this->entityManager->createQueryBuilder() ->select('o') ->from(Option::class, 'o') ->where('o.id = :option_id') ->setParameter('option_id', $id) ->getQuery() ->getOneOrNullResult(); } public function remove(Option $option) { $this->entityManager->remove($option); $this->entityManager->flush(); return true; } public function listNotIn(array $ids, int $templateId) { $qb = $this->entityManager->createQueryBuilder(); return $qb->select('o') ->from(Option::class, 'o') ->innerJoin('o.template', 't') ->where($qb->expr()->notIn('o.id', $ids)) ->andWhere('t.id = :templateId') ->andWhere('o.deletedAt is null') ->setParameter('templateId', $templateId) ->getQuery() ->getResult(); } public function list(int $templateId) { return $this->entityManager->createQueryBuilder() ->select('o') ->from(Option::class, 'o') ->innerJoin('o.template', 't') ->where('o.deletedAt is null') ->andWhere('t.id = :templateId') ->setParameter('templateId', $templateId) ->getQuery() ->getResult(); } }