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.

RotatingProductRepository.php 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace domain\Product\RotatingProduct;
  3. use domain\_\AbstractRepository;
  4. use domain\Product\Rotating\Rotating;
  5. class RotatingProductRepository extends AbstractRepository
  6. {
  7. protected RotatingProductRepositoryQuery $query;
  8. public function loadDependencies(): void
  9. {
  10. $this->loadQuery(RotatingProductRepositoryQuery::class);
  11. }
  12. public function getDefaultOptionsSearch(): array
  13. {
  14. return [
  15. self::WITH => [],
  16. self::JOIN_WITH => [],
  17. self::ORDER_BY => 'rotating_product.position ASC',
  18. self::ATTRIBUTE_ID_PRODUCER => ''
  19. ];
  20. }
  21. public function findRotatingProductsByRotating(Rotating $rotating)
  22. {
  23. return $this->createQuery()
  24. ->filterByRotating($rotating)
  25. ->find();
  26. }
  27. public function findOneLastRotatingProduct(Rotating $rotating): ?RotatingProduct
  28. {
  29. return $this->createQuery()
  30. ->filterByRotating($rotating)
  31. ->orderBy('rotating_product.position DESC')
  32. ->findOne();
  33. }
  34. }