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.

64 lines
2.3KB

  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($merchant = null) :QueryBuilder
  19. {
  20. if($merchant === false || $merchant===null)$merchant = $this->merchantUtils->getMerchantCurrent();
  21. return $this->createQueryBuilder('e')
  22. ->innerJoin('e.userMerchants', "userMerchants")
  23. ->andWhere('userMerchants.merchant = :currentMerchant')
  24. ->setParameter('currentMerchant', $$merchant) ;
  25. }
  26. public function findAllByNewsletter($newsletter)
  27. {
  28. return $this->createQueryBuilder('e')
  29. ->where(':newsletter MEMBER OF e.newsletters')
  30. ->setParameter('newsletter', $newsletter->getId())
  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. }