|
- <?php
-
- namespace domain\Product\RotatingProduct;
-
- use domain\_\AbstractRepository;
- use domain\Product\Rotating\Rotating;
-
- class RotatingProductRepository extends AbstractRepository
- {
- protected RotatingProductRepositoryQuery $query;
-
- public function loadDependencies(): void
- {
- $this->loadQuery(RotatingProductRepositoryQuery::class);
- }
-
- public function getDefaultOptionsSearch(): array
- {
- return [
- self::WITH => [],
- self::JOIN_WITH => [],
- self::ORDER_BY => 'rotating_product.position ASC',
- self::ATTRIBUTE_ID_PRODUCER => ''
- ];
- }
-
- public function findRotatingProductsByRotating(Rotating $rotating)
- {
- return $this->createQuery()
- ->filterByRotating($rotating)
- ->find();
- }
-
- public function findOneLastRotatingProduct(Rotating $rotating): ?RotatingProduct
- {
- return $this->createQuery()
- ->filterByRotating($rotating)
- ->orderBy('rotating_product.position DESC')
- ->findOne();
- }
- }
|