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.

48 lines
1.1KB

  1. <?php
  2. namespace common\logic\Config\TaxRate;
  3. use common\logic\AbstractRepository;
  4. class TaxRateRepository extends AbstractRepository
  5. {
  6. protected TaxRateRepositoryQuery $query;
  7. public function loadDependencies(): void
  8. {
  9. $this->query = $this->loadService(TaxRateRepositoryQuery::class);
  10. }
  11. public function getDefaultOptionsSearch(): array
  12. {
  13. return [
  14. 'with' => [],
  15. 'join_with' => [],
  16. 'orderby' => 'pourcent ASC',
  17. 'attribute_id_producer' => ''
  18. ] ;
  19. }
  20. public function findOneTaxRateById(int $id): ?TaxRate
  21. {
  22. return TaxRate::searchOne(['id' => $id]);
  23. }
  24. public function findTaxRates(): array
  25. {
  26. return TaxRate::find()->all();
  27. }
  28. // getTaxRateArray
  29. public function findTaxRatesAsArray(): array
  30. {
  31. $taxRateArrayReturn = [];
  32. $taxRateArray = $this->findTaxRates();
  33. foreach($taxRateArray as $taxRate) {
  34. $taxRateArrayReturn[$taxRate->id] = $taxRate;
  35. }
  36. return $taxRateArrayReturn;
  37. }
  38. }