PHP code example of misaf / vendra-currency
1. Go to this page and download the library: Download misaf/vendra-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/ */
misaf / vendra-currency example snippets
use Misaf\VendraCurrency\Models\Currency;
use Misaf\VendraCurrency\Support\CurrencyRegistry;
Currency::query()->create([
'code' => 'USD',
'name' => CurrencyRegistry::nameFor('USD'),
'symbol' => '$',
'decimal_places' => CurrencyRegistry::minorUnitFor('USD'),
'type' => CurrencyRegistry::typeFor('USD'),
'is_default' => true,
]);
CurrencyRegistry::options(); // ['USD' => 'US Dollar (USD)', ..., 'BTC' => 'BTC', ...]
CurrencyRegistry::isSupported('BTC'); // true
$currency = Currency::query()->where('code', 'USD')->firstOrFail();
$currency->formatAmount(1050); // "$10.50"
$currency->money(1050); // Cknow\Money\Money instance
use Misaf\VendraCurrency\Actions\SetDefaultCurrencyAction;
(new SetDefaultCurrencyAction())->execute($currency);
bash
composer vendor:publish --tag=vendra-currency-migrations
php artisan migrate
bash
php artisan vendor:publish --tag=vendra-currency-config
php artisan vendor:publish --tag=vendra-currency-translations
bash
php artisan test --compact --testsuite=vendra-currency
composer stan