PHP code example of flexmind-software / currency-rate

1. Go to this page and download the library: Download flexmind-software/currency-rate 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/ */

    

flexmind-software / currency-rate example snippets


return [
    'driver' => env('FLEXMIND_CURRENCY_RATE_DRIVER', 'european-central-bank'),
    'drivers' => [
        'albania',
        'armenia',
        'australia',
        'azerbaijan',
        'bceao',
        'belarus',
        'bosnia-and-herzegovina',
        'botswana',
        'bulgaria',
        'canada',
        'china',
        'croatia',
        'czech-republic',
        'denmark',
        'england',
        'european-central-bank',
        'fiji',
        'georgia',
        'hungary',
        'iceland',
        'israel',
        'macedonia',
        'moldavia',
        'norway',
        'poland',
        'romania',
        'russia',
        'serbia',
        'sweden',
        'switzerland',
        'turkey',
        'ukraine',
    ],
    'table-name' => env('FLEXMIND_CURRENCY_RATE_TABLENAME', 'currency_rates'),
    'cache-ttl' => env('FLEXMIND_CURRENCY_RATE_CACHE_TTL', 3600),
];

use FlexMindSoftware\CurrencyRate\Events\CurrencyRateSaved;
use Illuminate\Support\Facades\Event;

Event::listen(CurrencyRateSaved::class, function (CurrencyRateSaved $event) {
    // $event->rates contains the saved records
});

### Examples

Run for today's rates using all configured drivers:

bash
php artisan vendor:publish --provider="FlexMindSoftware\CurrencyRate\CurrencyRateProvider" --tag="currency-rate-migrations"
php artisan migrate
bash
php artisan vendor:publish --provider="FlexMindSoftware\CurrencyRate\CurrencyRateProvider" --tag="currency-rate-config"