mirror of
https://github.com/openclassify/openclassify.git
synced 2026-02-10 15:26:10 -06:00
Merge pull request #545 from openclassify/muhammet
function-currency-TL
This commit is contained in:
commit
e805752488
@ -5,6 +5,8 @@ use Visiosoft\AdvsModule\Adv\Command\appendRequestURL;
|
|||||||
use Visiosoft\AdvsModule\Adv\Command\GetAd;
|
use Visiosoft\AdvsModule\Adv\Command\GetAd;
|
||||||
use Visiosoft\AdvsModule\Adv\Command\isActive;
|
use Visiosoft\AdvsModule\Adv\Command\isActive;
|
||||||
use Visiosoft\AdvsModule\Adv\Command\LatestAds;
|
use Visiosoft\AdvsModule\Adv\Command\LatestAds;
|
||||||
|
use Visiosoft\AdvsModule\Currency\Currency;
|
||||||
|
use Visiosoft\AdvsModule\Currency\CurrencyFormat;
|
||||||
|
|
||||||
class AdvsModulePlugin extends Plugin
|
class AdvsModulePlugin extends Plugin
|
||||||
{
|
{
|
||||||
@ -25,6 +27,11 @@ class AdvsModulePlugin extends Plugin
|
|||||||
|
|
||||||
return $ad;
|
return $ad;
|
||||||
}
|
}
|
||||||
|
), new \Twig_SimpleFunction(
|
||||||
|
'currencyFormat',
|
||||||
|
function ($number, $currency = null, array $options = []) {
|
||||||
|
return app(CurrencyFormat::class)->format($number, $currency, $options);
|
||||||
|
}
|
||||||
), new \Twig_SimpleFunction(
|
), new \Twig_SimpleFunction(
|
||||||
'isActive',
|
'isActive',
|
||||||
function ($name, $type = 'module', $project = 'visiosoft') {
|
function ($name, $type = 'module', $project = 'visiosoft') {
|
||||||
|
|||||||
@ -0,0 +1,42 @@
|
|||||||
|
<?php namespace Visiosoft\AdvsModule\Currency;
|
||||||
|
use Anomaly\Streams\Platform\Support\Currency;
|
||||||
|
|
||||||
|
class CurrencyFormat
|
||||||
|
{
|
||||||
|
public function format($number, $currency = null, array $options = [])
|
||||||
|
{
|
||||||
|
$currency = strtoupper($currency ?: config('streams::currencies.default'));
|
||||||
|
|
||||||
|
$direction = array_get(
|
||||||
|
$options,
|
||||||
|
'direction',
|
||||||
|
config('streams::currencies.supported.' . $currency . '.direction', 'ltr')
|
||||||
|
);
|
||||||
|
$separator = array_get(
|
||||||
|
$options,
|
||||||
|
'separator',
|
||||||
|
config('streams::currencies.supported.' . $currency . '.separator', ',')
|
||||||
|
);
|
||||||
|
$decimals = array_get(
|
||||||
|
$options,
|
||||||
|
'decimals',
|
||||||
|
config('streams::currencies.supported.' . $currency . '.decimals', 2)
|
||||||
|
);
|
||||||
|
$point = array_get(
|
||||||
|
$options,
|
||||||
|
'point',
|
||||||
|
config('streams::currencies.supported.' . $currency . '.point', '.')
|
||||||
|
);
|
||||||
|
|
||||||
|
$prefix = null;
|
||||||
|
$suffix = null;
|
||||||
|
|
||||||
|
if (strtolower($direction) == 'ltr') {
|
||||||
|
|
||||||
|
$prefix = app(Currency::class)->symbol($currency);
|
||||||
|
} else {
|
||||||
|
$suffix = app(Currency::class)->symbol($currency);
|
||||||
|
}
|
||||||
|
return $prefix . number_format(($number * 100) / 100, $decimals, $point, $separator) . $suffix;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user