PHP code example of crgao / laravel-exchange-rates
1. Go to this page and download the library: Download crgao/laravel-exchange-rates library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace App\Http\Controllers;
use ExchangeRate;
class TestController extends Controller
{
public function index()
{
return ExchangeRate::currencies();
}
}
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);
}
}
namespace App\Http\Controllers;
use AshAllenDesign\LaravelExchangeRates\Classes\ExchangeRate;
class TestController extends Controller
{
public function index()
{
$exchangeRates = new ExchangeRate();
return $exchangeRates->convert(100, 'GBP', 'EUR', Carbon::now());
}
}
namespace App\Http\Controllers;
use AshAllenDesign\LaravelExchangeRates\Classes\ExchangeRate;
class TestController extends Controller
{
public function index()
{
$exchangeRates = new ExchangeRate();
return $exchangeRates->shouldBustCache()->convert(100, 'GBP', 'EUR', Carbon::now());
}
}
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());
}
}