quicktech-as/exchange-rate

Package Laravel to currency conversion using ExchangeRate API.
35
Install
composer require quicktech-as/exchange-rate
Latest Version:v0.1.1
PHP:>=5.4.0
License:MIT
Last Updated:Oct 30, 2018
Links: GitHub  ·  Packagist
Maintainer: gilberto-bueno

Quicktech\ExchangeRate (Laravel 5 Package)

Quicktech\ExchangeRate is a succinct and flexible way to use ExchangeRate API to convert currencies in Laravel 5 applications.

Contents

Installation

  1. In order to install Laravel 5, just add the following to your composer.json. Then run composer update:
"quicktech-as/exchange-rate": "^1.0"
  1. Open your config/app.php and add the following to the providers array:
Quicktech\ExchangeRate\ExchangeRateServiceProvider::class,
  1. In the same config/app.php and add the following to the aliases array:
'ExchangeRate' => Quicktech\ExchangeRate\Facade\ExchangeRate::class,
  1. Run the command below to publish the package config file config/exchange_rate.php:
php artisan vendor:publish

Configuration

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'

Usage

Get rates based on default currency

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.
]

Convert currency value

To convert currency value, you can use this resource:

$value = ExchangeRate::convert(10.00, 'USD', 'BRL');
// 31.11

License

Quicktech\ExchangeRate is free software distributed under the terms of the MIT license.

Contribution guidelines

Please report any issue you find in the issues page.
Pull requests are welcome.

Related Packages

elv1ss/currency

Handles currency for Laravel 5.

69 2
georgechaduneli/currency

This provides Laravel 5 with currency functions such as currency formatting and...

62 0
torann/currency

This provides Laravel with currency functions such as currency formatting and co...

1,150,620 402
casinelli/currency

Handles currency for Laravel 5.

11,848 17
davodavodavo3/currency

This provides Laravel 5 with currency functions such as currency formatting and...

2 0