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.

41 lines
1.0KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\User;
  3. use App\Entity\Merchant\Merchant;
  4. use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
  5. use Lc\SovBundle\Repository\User\UserRepositoryQuery as SovUserRepositoryQuery;
  6. class UserRepositoryQuery extends SovUserRepositoryQuery
  7. {
  8. use MerchantRepositoryQueryTrait;
  9. protected $isJoinUserMerchants = false;
  10. public function joinUserMerchants(): self
  11. {
  12. if (!$this->isJoinUserMerchants) {
  13. $this->isJoinUserMerchants = true;
  14. return $this
  15. ->innerJoin('.userMerchants', 'um');
  16. }
  17. return $this;
  18. }
  19. public function filterMerchantIsActive(): self
  20. {
  21. $this->joinUserMerchants();
  22. return $this
  23. ->andWhere('um.active = 1');
  24. }
  25. public function filterByMerchant(Merchant $merchant): self
  26. {
  27. $this->joinUserMerchants();
  28. return $this
  29. ->andWhere('um.merchant = :merchant')
  30. ->setParameter('merchant', $merchant);
  31. }
  32. }