This is a MNB Exchange Rate query package for Laravel v8 or above.
Package requires PHP v7.4 or above, with Soap and SimpleXml. Not tested with previous versions of Laravel.
This package is mainly based on top of MNB package and MNB Laravel package.
You can install the package via composer:
composer require greksazoo/mnb-exchange-laravel
php artisan vendor:publish --provider="Greksazoo\MnbExchangeLaravel\MnbExchangeLaravelServiceProvider" --tag="config"
/*
* Wsdl file location.
* */
'wsdl' => env('MNB_SOAP_WSDL', 'http://www.mnb.hu/arfolyamok.asmx?wsdl'),
'cache' => [
/*
* Desired cache driver for service.
* */
'store' => env('MNB_CACHE_DRIVER', 'file'),
/*
* Minutes the cached currencies will be held for.
* Default: 24hrs (1440)
* */
'timeout' => env('MNB_CACHE_MINUTES', 1440),
]
use Greksazoo\MnbExchangeLaravel\Facade\Mnb
$currency = Mnb::currentExchangeRate('EUR');
echo $currency->code; // 'EUR'
echo $currency->getCode(); // 'EUR'
echo $currency->unit; // '1'
echo $currency->getUnit(); // '1'
echo $currency->amount; // '350'
echo $currency->getAmount(); // '350'
$currency = app(\Greksazoo\MnbExchangeLaravel\MnbExchangeLaravel::class)->currentExchangeRate('EUR');
You can check the feed date by passing a $date variable to some methods. These methods will make variable to be a Carbon instance.
Mnb::exchangeRates($date);
$date->isToday();
These methods won't use and update cache.
- currentExchangeRate($code, &$date = null): Currency
- currentExchangeRates(&$date = null): array of Currency
These methods will use cache.
- exchangeRate($code, &$date = null): single Currency
- exchangeRates(&$date = null): array of currencies
- currencies(): array of strings (each is currency code)
- hasCurrency($code): bool
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the Laravel Package Boilerplate.