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.

51 lines
1.2KB

  1. <?php
  2. namespace common\logic\Config\TaxRate\Repository;
  3. use common\logic\AbstractRepository;
  4. use common\logic\Config\TaxRate\Model\TaxRate;
  5. class TaxRateRepository extends AbstractRepository
  6. {
  7. protected TaxRateRepositoryQuery $query;
  8. public function loadDependencies(): void
  9. {
  10. $this->loadQuery(TaxRateRepositoryQuery::class);
  11. }
  12. public function getDefaultOptionsSearch(): array
  13. {
  14. return [
  15. self::WITH => [],
  16. self::JOIN_WITH => [],
  17. self::ORDER_BY => 'pourcent ASC',
  18. self::ATTRIBUTE_ID_PRODUCER => ''
  19. ];
  20. }
  21. public function findOneTaxRateById(int $id): ?TaxRate
  22. {
  23. return $this->createQuery()
  24. ->filterById($id)
  25. ->findOne();
  26. }
  27. public function findTaxRates(): array
  28. {
  29. return $this->createQuery()
  30. ->find();
  31. }
  32. public function findTaxRatesAsArray(): array
  33. {
  34. $taxRateArrayReturn = [];
  35. $taxRateArray = $this->findTaxRates();
  36. foreach ($taxRateArray as $taxRate) {
  37. $taxRateArrayReturn[$taxRate->id] = $taxRate;
  38. }
  39. return $taxRateArrayReturn;
  40. }
  41. }