Require this package with composer using the following command:
composer require apvalkov/laravel-openexchangerates
Add the following class to the providers
array in config/app.php
:
Apvalkov\LaravelOpenexchangerates\ServiceProvider::class,
You can also publish the config file to change implementations (ie. interface to specific class).
php artisan vendor:publish --provider="Apvalkov\LaravelOpenexchangerates\ServiceProvider"
Set your openexchangerates app id
OPEN_EXCHANGE_RATES_APP_ID=your-app-id-here
// Latest
$rates = (new Openexchangerates())->latest(new LatestRatesRequest());
//Historical
$rates = (new Openexchangerates())->historical(new LatestRatesRequest(), Carbon::now());