They are provided to get information about exchange rates online.
There are two available options:
- Get latest rates.
- Get rates for a specific day.
latest
and historical
modes, respectively.
At the moment, the package supports and provides 3 different API providers:
Fixer
OpenExchangeRates
ExchangeRate
- default
You can choose whatever you like by changing it in the property rate_exchanger
of the config file.
In this case, you can add your own, 馃憖 see here for full details.
In order to get access to RateExchanger you can call the interface from Service Container like this:
use PostScripton\Money\Clients\RateExchangers\RateExchanger;
app(RateExchanger::class)->supports(['USD', 'RUB']);
app(RateExchanger::class)->rate('USD', 'RUB', now()->subYear());
Or you can use a cached variant because it implements the interface as well:
use PostScripton\Money\Cache\RateExchangerCache;
use PostScripton\Money\Currencies;
app(RateExchangerCache::class)->supports(Currencies::getCodesArray());
app(RateExchangerCache::class)->rate('USD', 'RUB', now()->subYear());
app(RateExchangerCache::class)->clear(); // deletes all cached data
馃搶 Back to the contents.