Package Data | |
---|---|
Maintainer Username: | gilberto-bueno |
Maintainer Contact: | gilberto@quicktech.no (Gilberto) |
Package Create Date: | 2017-05-05 |
Package Last Update: | 2018-10-30 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-19 03:14:29 |
Package Statistics | |
---|---|
Total Downloads: | 34 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 1 |
Total Forks: | 1 |
Total Open Issues: | 0 |
Quicktech\ExchangeRate is a succinct and flexible way to use ExchangeRate API to convert currencies in Laravel 5 applications.
composer update
:"quicktech-as/exchange-rate": "^1.0"
config/app.php
and add the following to the providers
array:Quicktech\ExchangeRate\ExchangeRateServiceProvider::class,
config/app.php
and add the following to the aliases
array:'ExchangeRate' => Quicktech\ExchangeRate\Facade\ExchangeRate::class,
config/exchange_rate.php
:php artisan vendor:publish
Open your .env
file and setup your ExchangeRate credentials:
EXCHANGERATE_DEFAULT_CURRENCY = 'your default currency'
EXCHANGERATE_API_KEY = 'your api key'
EXCHANGERATE_API_URI = 'https://v3.exchangerate-api.com'
To get all rates based on your defult currency, you can use this resource:
$rates = ExchangeRate::rates();
The method above will return the following response:
[
"AUD" => 1.32230,
"BGN" => 1.8096,
"BRL" => 3.11,
"..." => 1.31135,
"..." => 7.473, etc. etc.
]
To convert currency value, you can use this resource:
$value = ExchangeRate::convert(10.00, 'USD', 'BRL');
// 31.11
Quicktech\ExchangeRate is free software distributed under the terms of the MIT license.
Please report any issue you find in the issues page.
Pull requests are welcome.