createQueryBuilder('e') ->innerJoin('e.userMerchants', "userMerchants") ->andWhere('userMerchants.merchant = :currentMerchant') ->setParameter('currentMerchant', $this->merchantUtils->getMerchantCurrent()->getId()) ; } public function findAllByNewsletter($newsletter) { return $this->createQueryBuilder('e') ->where(':newsletter MEMBER OF e.newsletters') ->setParameter('newsletter', $newsletter->getId()) ->andWhere('e.enabled = 1') ->innerJoin('e.userMerchants', 'um') ->andWhere('um.merchant = :merchant AND um.active = 1') ->setParameter('merchant', $newsletter->getMerchant()) ->getQuery() ->getResult(); } public function findByRole($role) { $qb = $this->createQueryBuilder('u') ->where('u.roles LIKE :roles') ->setParameter('roles', '%"' . $role . '"%'); return $qb->getQuery()->getResult(); } }