laravel-exchange-rates

A Laravel wrapper package for interacting with the exchangeratesapi.io API.

MIT License

Downloads
314.9K
Stars
439
Committers
9

Bot releases are hidden (Show)

laravel-exchange-rates - Laravel Exchange Rates v3.1.0

Published by ash-jc-allen about 4 years ago

Laravel Exchange Rate v3.1.0

New Features

Laravel Exchange Rates comes with its own ValidCurrency rule for validating currencies. This can be useful for if you need to be sure that a currency (maybe one provided by the user) is supported by the library.

The example below show how you can use the rule for validating the currency:

<?php
    
namespace App\Http\Controllers;

use AshAllenDesign\LaravelExchangeRates\Rules\ValidCurrency;
use Illuminate\Support\Facades\Validator;

class TestController extends Controller
{
    public function index()
    {
        $formData = [
            'currency' => 'GBP',
        ];

        $rules = [
            'currency' => new ValidCurrency,
        ];

        $validator = Validator::make($formData, $rules);
    }
}
laravel-exchange-rates - Laravel Exchange Rates v3.0.0

Published by ash-jc-allen over 4 years ago

Laravel Exchange Rate v3.0.0

New Features

This feature brings huge improvements to the performance and usage of this library. Previously, if you wanted to get the exchange rate for more than one exchange rate you would have to call the package's method multiple times (once for each currency).

As of Laravel Exchange Rates v3.0.0, you can now get the exchange rates and converted values for multiple currencies at once. This reduces the amount of requests that are needed to be made to the API and reduces overall load.

The example below show how to convert £1 'GBP' to 'EUR' and 'USD' at today's exchange rate.

$exchangeRates = new ExchangeRate();
$result = $exchangeRates->convert(100, 'GBP', ['EUR', 'USD'], Carbon::now());

// $result: [
//     'EUR' => 110.15884906,
//     'USD' => 125.30569081
// ];

A new ->shouldCache() method has now been added that can be used to determine whether if the exchange rate fetched via the API should be stored in the cache.

The example below shows how to use the new method get an exchange rate and not cache it:

<?php
    
    namespace App\Http\Controllers;
    
    use AshAllenDesign\LaravelExchangeRates\Classes\ExchangeRate;
    
    class TestController extends Controller
    {
        public function index()
        {
            $exchangeRates = new ExchangeRate();
            return $exchangeRates->shouldCache(false)->convert(100, 'GBP', 'EUR', Carbon::now());
        }
    }

As of Laravel Exchange Rates v3.0.0, Laravel 5.8 is no longer supported. Therefore, you must be using a minimum of Laravel 6.0 to use this library.

laravel-exchange-rates - Laravel Exchange Rates v2.2.0

Published by ash-jc-allen over 4 years ago

Laravel Exchange Rates v2.2.0

New Features

Laravel Exchange Rates uses the exchangeratesapi.io service for fetching the exchange rates between different currencies. At the time of releasing v2.2.0, a bug exists in the API that caused an exception if trying to convert from EUR to EUR.

To solve this issue, a change has now been made that prevents any requests from being sent to the API if the from and to currencies are the same. This also brings some minor performance improvements.

This is only a small update purely for cosmetic reasons. It changes the list of support currencies in the documentation from an unordered list to a table.

laravel-exchange-rates - Laravel Exchange Rates v2.1.0

Published by ash-jc-allen over 4 years ago

Laravel Exchange Rates v2.1.0

New Features

Laravel Exchange Rates now has support for Laravel 7!

Package Rankings
Top 4.48% on Packagist.org
Badges
Extracted from project README
Battle Ready Laravel
Related Projects