Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

53 rindas
2.0KB

  1. <?php
  2. namespace Lc\ShopBundle\Repository;
  3. use Doctrine\ORM\QueryBuilder;
  4. use Lc\ShopBundle\Context\DefaultRepositoryInterface;
  5. use Lc\ShopBundle\Context\UserInterface;
  6. /**
  7. * @method UserInterface|null find($id, $lockMode = null, $lockVersion = null)
  8. * @method UserInterface|null findOneBy(array $criteria, array $orderBy = null)
  9. * @method UserInterface[] findAll()
  10. * @method UserInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  11. */
  12. class UserRepository extends BaseRepository implements DefaultRepositoryInterface
  13. {
  14. public function getInterfaceClass()
  15. {
  16. return UserInterface::class;
  17. }
  18. public function findByMerchantQuery() :QueryBuilder
  19. {
  20. return $this->createQueryBuilder('e')
  21. ->innerJoin('e.userMerchants', "userMerchants")
  22. ->andWhere('userMerchants.merchant = :currentMerchant')
  23. ->setParameter('currentMerchant', $this->merchantUtils->getMerchantCurrent()->getId()) ;
  24. }
  25. public function findAllByNewsletter($newsletter)
  26. {
  27. return $this->createQueryBuilder('e')
  28. ->where(':newsletter MEMBER OF e.newsletters')
  29. ->setParameter('newsletter', $newsletter->getId())
  30. ->andWhere('e.enabled = 1')
  31. ->innerJoin('e.userMerchants', 'um')
  32. ->andWhere('um.merchant = :merchant AND um.active = 1')
  33. ->setParameter('merchant', $newsletter->getMerchant())
  34. ->getQuery()
  35. ->getResult();
  36. }
  37. public function findByRole($role)
  38. {
  39. $qb = $this->createQueryBuilder('u')
  40. ->where('u.roles LIKE :roles')
  41. ->setParameter('roles', '%"' . $role . '"%');
  42. return $qb->getQuery()->getResult();
  43. }
  44. }