Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

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->query = $this->loadService(PointSaleDistributionRepositoryQuery::class);
  13. }
  14. public function getDefaultOptionsSearch(): array
  15. {
  16. return [
  17. 'with' => ['distribution', 'pointSale'],
  18. 'join_with' => [],
  19. 'orderby' => '',
  20. 'attribute_id_producer' => ''
  21. ] ;
  22. }
  23. public function findOnePointSaleDistribution(Distribution $distribution, PointSale $pointSale): ?PointSaleDistribution
  24. {
  25. return PointSaleDistribution::searchOne([
  26. 'id_distribution' => $distribution->id,
  27. 'id_point_sale' => $pointSale->id
  28. ]);
  29. }
  30. public function findPointSaleDistributionsByDistribution(Distribution $distribution): array
  31. {
  32. return PointSaleDistribution::searchAll([
  33. 'id_distribution' => $distribution->id
  34. ]) ;
  35. }
  36. public function countPointSaleDistributionsByDistribution(Distribution $distribution): int
  37. {
  38. return PointSaleDistribution::searchCount([
  39. 'id_distribution' => $distribution->id
  40. ]);
  41. }
  42. }