You can install the package via composer:
composer require flexmind-software/currency-rateYou can publish and run the migrations with:
php artisan vendor:publish --provider="FlexMindSoftware\CurrencyRate\CurrencyRateProvider" --tag="currency-rate-migrations"
php artisan migrateYou can publish the config file with:
php artisan vendor:publish --provider="FlexMindSoftware\CurrencyRate\CurrencyRateProvider" --tag="currency-rate-config"This is the contents of the published config file:
return [
'driver' => env('FLEXMIND_CURRENCY_RATE_DRIVER', 'european-central-bank'),
'drivers' => [
'albania',
'armenia',
'australia',
'azerbaijan',
'bceao',
'belarus',
'bosnia-and-herzegovina',
'botswana',
'bulgaria',
'canada',
'china',
'croatia',
'czech-republic',
'denmark',
'england',
'european-central-bank',
'fiji',
'georgia',
'hungary',
'iceland',
'israel',
'macedonia',
'moldavia',
'norway',
'poland',
'romania',
'russia',
'serbia',
'sweden',
'switzerland',
'turkey',
'ukraine',
],
'table-name' => env('FLEXMIND_CURRENCY_RATE_TABLENAME', 'currency_rates'),
'cache-ttl' => env('FLEXMIND_CURRENCY_RATE_CACHE_TTL', 3600),
];The drivers array defines which currency rate providers are available when running
the command with --driver=all. Add or remove entries from this list to customise
the drivers used in your application. See config/currency-rate.php for additional configuration options, including the cache TTL for HTTP requests.
| Country / Source | Driver |
|---|---|
| Albania | albania |
| Armenia | armenia |
| Australia | australia |
| Azerbaijan | azerbaijan |
| BCEAO | bceao |
| Belarus | belarus |
| Bosnia and Herzegovina | bosnia-and-herzegovina |
| Botswana | botswana |
| Bulgaria | bulgaria |
| Canada | canada |
| China | china |
| Croatia | croatia |
| Czech Republic | czech-republic |
| Denmark | denmark |
| England | england |
| European Central Bank | european-central-bank |
| Fiji | fiji |
| Georgia | georgia |
| Hungary | hungary |
| Iceland | iceland |
| Israel | israel |
| Macedonia | macedonia |
| Moldavia | moldavia |
| Norway | norway |
| Poland | poland |
| Romania | romania |
| Russia | russia |
| Serbia | serbia |
| Sweden | sweden |
| Switzerland | switzerland |
| Turkey | turkey |
| Ukraine | ukraine |
php artisan flexmind:currency-rate [options] [--] [<date>]
Arguments:
date Date to download currency rate, if empty is today
Options:
--queue[=QUEUE] Queue name, if set "none" cmd run without add job to queue [default: "none"]
--driver[=DRIVER] Driver to download rate [default: "all"]The CurrencyRate::saveIn method dispatches a CurrencyRateSaved event once rates are persisted. Consumers may listen for this event to trigger downstream actions:
use FlexMindSoftware\CurrencyRate\Events\CurrencyRateSaved;
use Illuminate\Support\Facades\Event;
Event::listen(CurrencyRateSaved::class, function (CurrencyRateSaved $event) {
// $event->rates contains the saved records
});
### Examples
Run for today's rates using all configured drivers:
```bash
php artisan flexmind:currency-rateFetch rates for a specific date:
php artisan flexmind:currency-rate 2023-09-15Use a specific driver:
php artisan flexmind:currency-rate --driver=canadaDispatch the job to a queue:
php artisan flexmind:currency-rate --queue=defaultExecute immediately without queueing:
php artisan flexmind:currency-rate --queue=nonecomposer testPlease see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Translations for driver descriptions live in resources/langs/{locale}/description.php.
To contribute a new locale:
- Create a new directory for the locale under
resources/langs(for exampleesfor Spanish). - Copy
resources/langs/en/description.phpinto that directory and translate the strings. - Submit a pull request with the new translation file.
The MIT License (MIT). Please see License File for more information.