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.

34 lines
844B

  1. <?php
  2. namespace Lc\CaracoleBundle\Repository;
  3. use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
  4. use Lc\CaracoleBundle\Model\Section\SectionInterface;
  5. trait SectionRepositoryQueryTrait
  6. {
  7. protected bool $isJoinSection = false;
  8. public function filterBySection(SectionInterface $section)
  9. {
  10. return $this->andWhereSection($this->id, $section);
  11. }
  12. public function filterByMerchantViaSection(MerchantInterface $merchant)
  13. {
  14. $this->joinSection();
  15. return $this->andWhere('s.merchant = :merchant')
  16. ->setParameter('merchant', $merchant);
  17. }
  18. public function joinSection(): self
  19. {
  20. if (!$this->isJoinSection) {
  21. $this->isJoinSection = true;
  22. return $this
  23. ->leftJoin('.section', 's');
  24. }
  25. return $this;
  26. }
  27. }