Skip to content
Advertisement

antonioribeiro/countries How to get currency symbol directly from country selection?

I am not sure if this is a correct channel for the package question, But I am using this package, https://github.com/antonioribeiro/countries. Documentation is not much clear.

I can get currency symbol with the below code,

$all = $countries->where('name.common', 'India')->first()->hydrateCurrencies()->currencies;

dd($all->INR->units->major->symbol);

But in the second line of code, I must specify INR to get the symbol. But as per requirements, I must get a symbol by just specifying which country is selected in where statement,

Has anyone idea about this package?

Thanks,

Advertisement

Answer

you can use the ->first() method to get the most common currency in that country.

So in your example it would be

echo $all->first()->units->major->symbol;

I’ve just replaced INR with first()

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement