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.

49 lines
1.1KB

  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->query = $this->loadService(TaxRateRepositoryQuery::class);
  11. }
  12. public function getDefaultOptionsSearch(): array
  13. {
  14. return [
  15. 'with' => [],
  16. 'join_with' => [],
  17. 'orderby' => 'pourcent ASC',
  18. 'attribute_id_producer' => ''
  19. ] ;
  20. }
  21. public function findOneTaxRateById(int $id): ?TaxRate
  22. {
  23. return TaxRate::searchOne(['id' => $id]);
  24. }
  25. public function findTaxRates(): array
  26. {
  27. return TaxRate::find()->all();
  28. }
  29. // getTaxRateArray
  30. public function findTaxRatesAsArray(): array
  31. {
  32. $taxRateArrayReturn = [];
  33. $taxRateArray = $this->findTaxRates();
  34. foreach($taxRateArray as $taxRate) {
  35. $taxRateArrayReturn[$taxRate->id] = $taxRate;
  36. }
  37. return $taxRateArrayReturn;
  38. }
  39. }