You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UserRepository.php 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. public function findByTicketTypesNotification($ticketType){
  45. $qb = $this->createQueryBuilder('u')
  46. ->where('u.ticketTypesNotification LIKE :ticketType')
  47. ->setParameter('ticketType', '%"' . $ticketType . '"%');
  48. return $qb->getQuery()->getResult();
  49. }
  50. }