您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

CreateCurrencyFromAccount.php 956B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace App\Actions\Banking;
  3. use App\Models\Setting\Currency;
  4. use Illuminate\Support\Facades\Auth;
  5. class CreateCurrencyFromAccount
  6. {
  7. public function create(string $code, string $name, string $rate): Currency
  8. {
  9. $companyId = Auth::user()->currentCompany->id;
  10. $hasDefaultCurrency = Currency::where('company_id', $companyId)->where('enabled', true)->exists();
  11. return Currency::create([
  12. 'name' => $name,
  13. 'code' => $code,
  14. 'rate' => $rate,
  15. 'precision' => config("money.{$code}.precision"),
  16. 'symbol' => config("money.{$code}.symbol"),
  17. 'symbol_first' => config("money.{$code}.symbol_first"),
  18. 'decimal_mark' => config("money.{$code}.decimal_mark"),
  19. 'thousands_separator' => config("money.{$code}.thousands_separator"),
  20. 'enabled' => !$hasDefaultCurrency,
  21. 'company_id' => $companyId,
  22. ]);
  23. }
  24. }