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.

50 lines
1.5KB

  1. <?php
  2. namespace common\logic\Distribution\PointSaleDistribution\Repository;
  3. use common\logic\AbstractRepository;
  4. use common\logic\Distribution\Distribution\Model\Distribution;
  5. use common\logic\Distribution\PointSaleDistribution\Model\PointSaleDistribution;
  6. use common\logic\PointSale\PointSale\Model\PointSale;
  7. class PointSaleDistributionRepository extends AbstractRepository
  8. {
  9. protected PointSaleDistributionRepositoryQuery $query;
  10. public function loadDependencies(): void
  11. {
  12. $this->loadQuery(PointSaleDistributionRepositoryQuery::class);
  13. }
  14. public function getDefaultOptionsSearch(): array
  15. {
  16. return [
  17. self::WITH => ['distribution', 'pointSale'],
  18. self::JOIN_WITH => [],
  19. self::ORDER_BY => '',
  20. self::ATTRIBUTE_ID_PRODUCER => ''
  21. ];
  22. }
  23. public function findOnePointSaleDistribution(Distribution $distribution, PointSale $pointSale): ?PointSaleDistribution
  24. {
  25. return $this->createDefaultQuery()
  26. ->filterByDistribution($distribution)
  27. ->filterByPointSale($pointSale)
  28. ->findOne();
  29. }
  30. public function findPointSaleDistributionsByDistribution(Distribution $distribution): array
  31. {
  32. return $this->createDefaultQuery()
  33. ->filterByDistribution($distribution)
  34. ->find();
  35. }
  36. public function countPointSaleDistributionsByDistribution(Distribution $distribution): int
  37. {
  38. return $this->createDefaultQuery()
  39. ->filterByDistribution($distribution)
  40. ->count();
  41. }
  42. }