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.

37 line
992B

  1. <?php
  2. namespace domain\Product\Product;
  3. use domain\Distribution\Distribution\Distribution;
  4. use domain\Product\ProductCategory\ProductCategory;
  5. use domain\_\AbstractRepositoryQuery;
  6. class ProductRepositoryQuery extends AbstractRepositoryQuery
  7. {
  8. protected ProductDefinition $definition;
  9. public function loadDependencies(): void
  10. {
  11. $this->loadDefinition(ProductDefinition::class);
  12. }
  13. public function filterByName(string $name): self
  14. {
  15. $this->andWhere(['name' => $name]);
  16. return $this;
  17. }
  18. public function filterByDistribution(Distribution $distribution): self
  19. {
  20. $this->andWhere(['product_distribution.id_distribution' => $distribution->id]);
  21. return $this;
  22. }
  23. public function filterByProductCategory(ProductCategory $productCategory = null) : self
  24. {
  25. if($productCategory) {
  26. $this->andWhere(['product.id_product_category' => $productCategory->id]);
  27. }
  28. return $this;
  29. }
  30. }