@csrf @php $currencies = \App\Models\Currency::orderByDesc('is_primary')->orderBy('code')->get(); $defaultCurrency = optional($currencies->firstWhere('is_primary',true))->id; $currencyRates = $currencies->map(fn($c)=>[ 'id' => $c->id, 'code' => $c->code, 'rate' => (float)$c->rate_to_primary, 'is_primary' => (bool)$c->is_primary, ]); @endphp