Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

ProductDistributionRepository.php 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace domain\Distribution\ProductDistribution;
  3. use domain\Distribution\Distribution\Distribution;
  4. use domain\Product\Product\Product;
  5. use domain\_\AbstractRepository;
  6. class ProductDistributionRepository extends AbstractRepository
  7. {
  8. protected ProductDistributionRepositoryQuery $query;
  9. public function loadDependencies(): void
  10. {
  11. $this->loadQuery(ProductDistributionRepositoryQuery::class);
  12. }
  13. public function getDefaultOptionsSearch(): array
  14. {
  15. return [
  16. self::WITH => ['product','distribution'],
  17. self::JOIN_WITH => [],
  18. self::ORDER_BY => '',
  19. self::ATTRIBUTE_ID_PRODUCER => ''
  20. ] ;
  21. }
  22. public function findOneProductDistribution(Distribution $distribution, Product $product): ?ProductDistribution
  23. {
  24. return $this->createDefaultQuery()
  25. ->filterByDistribution($distribution)
  26. ->filterByProduct($product)
  27. ->findOne();
  28. }
  29. public function findProductDistributionsByDistribution(Distribution $distribution): array
  30. {
  31. return $this->createDefaultQuery()
  32. ->filterByDistribution($distribution)
  33. ->find();
  34. }
  35. public function countProductDistributionsByDistribution(Distribution $distribution): int
  36. {
  37. return $this->createDefaultQuery()
  38. ->filterByDistribution($distribution)
  39. ->count();
  40. }
  41. }