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.9KB

3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. protected $isJoinAddresses = false;
  11. public function joinUserMerchants(): self
  12. {
  13. if (!$this->isJoinUserMerchants) {
  14. $this->isJoinUserMerchants = true;
  15. return $this
  16. ->leftJoin('.userMerchants', 'userMerchants');
  17. }
  18. return $this;
  19. }
  20. public function joinAddresses(): self
  21. {
  22. if (!$this->isJoinAddresses) {
  23. $this->isJoinAddresses = true;
  24. return $this
  25. ->innerJoin('.addresses', 'addresses');
  26. }
  27. return $this;
  28. }
  29. public function filterMerchantIsActive(): self
  30. {
  31. $this->joinUserMerchants();
  32. return $this
  33. ->andWhere('userMerchants.active = 1');
  34. }
  35. public function filterByMerchant(Merchant $merchant): self
  36. {
  37. $this->joinUserMerchants();
  38. return $this
  39. ->andWhere('userMerchants.merchant = :merchant')
  40. ->setParameter('merchant', $merchant);
  41. }
  42. public function filterByExtraInfoZip(string $zip)
  43. {
  44. $this->joinAddresses();
  45. return $this
  46. ->andWhere('.extraInfoZip LIKE :extraInfoZip OR addresses.zip LIKE :extraInfoZip')
  47. ->setParameter('extraInfoZip', $zip);
  48. }
  49. public function filterByExtraInfoCity(string $city)
  50. {
  51. $this->joinAddresses();
  52. return $this
  53. ->andWhere('.extraInfoCity LIKE :extraInfoCity OR addresses.city LIKE :extraInfoCity')
  54. ->setParameter('extraInfoCity', $city);
  55. }
  56. }