Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

PointSaleRepositoryQuery.php 1.9KB

3 år sedan
3 år sedan
3 år sedan
3 år sedan
3 år sedan
3 år sedan
3 år sedan
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\PointSale;
  3. use Knp\Component\Pager\PaginatorInterface;
  4. use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
  5. use Lc\SovBundle\Model\User\UserInterface;
  6. use Lc\SovBundle\Repository\AbstractRepositoryQuery;
  7. class PointSaleRepositoryQuery extends AbstractRepositoryQuery
  8. {
  9. protected $isJoinUserPointSales = false;
  10. public function __construct(PointSaleRepository $repository, PaginatorInterface $paginator)
  11. {
  12. parent::__construct($repository, 'pointSale', $paginator);
  13. }
  14. public function filterByUser(UserInterface $user): self
  15. {
  16. $this->joinUserPointSales();
  17. return $this
  18. ->andWhere('userPointSales.user = :user')
  19. ->setParameter('user', $user);
  20. }
  21. public function filterByMerchant(MerchantInterface $merchant)
  22. {
  23. return $this
  24. ->andWhere(':merchant MEMBER OF .merchants')
  25. ->setParameter(':merchant', $merchant);
  26. }
  27. public function filterIsNotPublic(): self
  28. {
  29. return $this->andWhere('.isPublic = 0');
  30. }
  31. public function filterIsPublic(): self
  32. {
  33. return $this->andWhere('.isPublic = 1');
  34. }
  35. public function filterByIsPublic(int $isPublic): self
  36. {
  37. return $this->andWhere('.isPublic = ' . $isPublic);
  38. }
  39. public function filterLikeCode(string $code): self
  40. {
  41. return $this
  42. ->andWhere('.code LIKE :code')
  43. ->setParameter('code', $code);
  44. }
  45. public function joinUserPointSales(): self
  46. {
  47. if (!$this->isJoinUserPointSales) {
  48. $this->isJoinUserPointSales = true;
  49. return $this
  50. ->innerJoin('.userPointSales', 'userPointSales');
  51. }
  52. return $this;
  53. }
  54. public function innerJoinDeliveryAvailabilityPointSale()
  55. {
  56. return $this->innerJoin('.deliveryAvailabilityPointSale');
  57. }
  58. }