PHP code example of onuraycicek / currency

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

    

onuraycicek / currency example snippets


@stack("footer")

<x-currency-table select-active></x-currency-table>

$fromId = 53;
$toId = 155;
$amount = 100;
echo \Onuraycicek\Currency\Currency::convertWithId($fromId, $toId, $amount);

$fromCurrencyCode = 'TRY';
$toCurrencyCode = 'USD';
$amount = 100;
echo \Onuraycicek\Currency\Currency::convert($fromCurrencyCode, $toCurrencyCode, $amount);

var_dump(\Onuraycicek\Currency\Currency::getActiveCurrencies());

$currencyCode = 'TRY';
var_dump(\Onuraycicek\Currency\Currency::getCurrency('TRY'));

$currencyId = 1;
var_dump(\Onuraycicek\Currency\Currency::getCurrencyById($currencyId));

var_dump(\Onuraycicek\Currency\Models\Currency::all());

return [
    'theme' => 'bootstrap5',
    'currencies' => ['TRY', 'USD', 'EUR'], // if it is null, currencies with status 1 will be shown. -> ('currencies' => null)
];

theme: bootstrap5, bootstrap4 (not supported yet)
currencies: https://www.html-code-generator.com/php/array/currency-names
bash
php artisan vendor:publish --tag="currency-migrations"
php artisan vendor:publish --tag="currency-config"
php artisan vendor:publish --tag="currency-seeder"
php artisan migrate
php artisan db:seed --class=CurrencySeeder