Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

UserRepository.php 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. ->innerJoin('e.userMerchants', 'um')
  31. ->andWhere('um.merchant = :merchant AND um.active = 1')
  32. ->setParameter('merchant', $newsletter->getMerchant())
  33. ->getQuery()
  34. ->getResult();
  35. }
  36. public function findByRole($role)
  37. {
  38. $qb = $this->createQueryBuilder('u')
  39. ->where('u.roles LIKE :roles')
  40. ->setParameter('roles', '%"' . $role . '"%');
  41. return $qb->getQuery()->getResult();
  42. }
  43. public function findByTicketTypesNotification($ticketType){
  44. $qb = $this->createQueryBuilder('u')
  45. ->where('u.ticketTypesNotification LIKE :ticketType')
  46. ->setParameter('ticketType', '%"' . $ticketType . '"%');
  47. return $qb->getQuery()->getResult();
  48. }
  49. }