|
12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
-
- namespace domain\Product\Product;
-
- use domain\Distribution\Distribution\Distribution;
- use domain\Product\ProductCategory\ProductCategory;
- use domain\_\AbstractRepositoryQuery;
-
- class ProductRepositoryQuery extends AbstractRepositoryQuery
- {
- protected ProductDefinition $definition;
-
- public function loadDependencies(): void
- {
- $this->loadDefinition(ProductDefinition::class);
- }
-
- public function filterByName(string $name): self
- {
- $this->andWhere(['name' => $name]);
- return $this;
- }
-
- public function filterByDistribution(Distribution $distribution): self
- {
- $this->andWhere(['product_distribution.id_distribution' => $distribution->id]);
- return $this;
- }
-
- public function filterByProductCategory(ProductCategory $productCategory = null) : self
- {
- if($productCategory) {
- $this->andWhere(['product.id_product_category' => $productCategory->id]);
- }
- return $this;
- }
- }
|