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.

UserRepositoryQuery.php 1.0KB

3 anni fa
3 anni fa
3 anni fa
3 anni fa
3 anni fa
3 anni fa
1234567891011121314151617181920212223242526272829303132333435363738394041
  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', 'userMerchants');
  16. }
  17. return $this;
  18. }
  19. public function filterMerchantIsActive(): self
  20. {
  21. $this->joinUserMerchants();
  22. return $this
  23. ->andWhere('userMerchants.active = 1');
  24. }
  25. public function filterByMerchant(Merchant $merchant): self
  26. {
  27. $this->joinUserMerchants();
  28. return $this
  29. ->andWhere('userMerchants.merchant = :merchant')
  30. ->setParameter('merchant', $merchant);
  31. }
  32. }