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.

PointSaleDistributionRepository.php 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. }