Skip to content

pauljohnston/laravel-open-exchange-rates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

laravel-open-exchange-rates

This package provides a simple and convenient interface for working with the Open Exchange Rates service. Currently supports free endpoints.

Installation Via Composer

Add this to your composer.json file, in the require object:

"equentor/laravel-open-exchange-rates": "dev-master"

After that, run composer install to install the package. Add the service provider to app/config/app.php, within the providers array:

'providers' => [
    // ...
    Equentor\LaravelOpenExchangeRates\LOERServiceProvider::class,
]

Lastly, publish the config file.

php artisan vendor:publish

Usage example

In config/loer.php

return [
    'app_id' => '*****************************', // your own api key
    'default_base_currency' => 'USD'
];

In controller (or service) method:

use Equentor\LaravelOpenExchangeRates\Client;

class SomeController extends Controller
{
    private $client;
    
    public function __construct(Client $client)
    {
        $this->client = $client;
    }
    
    public function someAction()
    {
        $coefficient = $this->client->latest('USD,RUB,AWG');
        
        $historical_coefficent $this->client->historical('2011-03-05', 'USD,RUB,AWG');
        
        // e.t.c...
        
        // Change in base currencies (not allowed for free account) and requests for the coefficients of all currencies relative to.
        $coefficient = $this->client->currency('RUB')->latest();
    }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages