Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

68 lines
1.8KB

  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. }