szunisoft / laravel-mnb
Laravel MNB (Magyar Nemzeti Bank)
v2.0.1
2020-03-24 18:24 UTC
Requires
- php: ^7.1.3
- illuminate/cache: 5.* | 6.* | 7.*
- illuminate/support: 5.* | 6.* | 7.*
- szunisoft/mnb: ^1.0.1
Requires (Dev)
- mockery/mockery: 1.3.*
- orchestra/testbench: ^5.1.0
- phpunit/phpunit: ^8.5
README
Requirements
Package requires Soap and version 7.1 of PHP or higher.
Know-how
This package was built on top of this MNB package. Please check out for corresponding documentations.
Install
composer require szunisoft/laravel-mnb
Configuration
Export
php artisan vendor:publish --provider="SzuniSoft\Mnb\Laravel\MnbServiceProvider" --tag="config"
config/mnb-exchange.php
/* * 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) * */ 'minutes' => env('MNB_CACHE_MINUTES', 1440), ]
Usage
Access via facade
use SzuniSoft\Mnb\Laravel\Facade\Mnb $currency = Mnb::currentExchangeRate('EUR');
Resolve by application container
$currency = app(\SzuniSoft\Mnb\Laravel\Client::class)->currentExchangeRate('EUR');
Access refresh date by reference
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();
Available methods
Won't use cache
These methods won't use and update cache.
- currentExchangeRate($code, &$date = null): Currency
- currentExchangeRates(&$date = null): array of Currency
Will use cache
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