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.

CreateCurrency.php 905B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace App\Actions\OptionAction;
  3. use App\Models\Setting\Currency;
  4. use App\Utilities\Currency\CurrencyAccessor;
  5. class CreateCurrency
  6. {
  7. public function create(string $code, string $name, string $rate): Currency
  8. {
  9. $defaultCurrency = CurrencyAccessor::getDefaultCurrency();
  10. $hasDefaultCurrency = $defaultCurrency !== null;
  11. $currency_code = currency($code);
  12. return Currency::create([
  13. 'name' => $name,
  14. 'code' => $code,
  15. 'rate' => $rate,
  16. 'precision' => $currency_code->getPrecision(),
  17. 'symbol' => $currency_code->getSymbol(),
  18. 'symbol_first' => $currency_code->isSymbolFirst(),
  19. 'decimal_mark' => $currency_code->getDecimalMark(),
  20. 'thousands_separator' => $currency_code->getThousandsSeparator(),
  21. 'enabled' => ! $hasDefaultCurrency,
  22. ]);
  23. }
  24. }