Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

54 lines
1.5KB

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