feat(helper): membuat method percentage dan memperbaiki method formatCurrency menjadi currency dan isinya

This commit is contained in:
Yoga Pangestu 2025-09-25 19:23:13 +07:00
parent df41581385
commit b0d2224880

View File

@ -3,10 +3,10 @@
use Illuminate\Support\Number;
use Illuminate\Support\Str;
if (! function_exists('formatCurrency')) {
function formatCurrency(string $value, ?string $format = 'IDR', ?string $locale = 'id_ID', int $precision = 0): string
if (! function_exists('currency')) {
function currency(string $value, ?string $currency = null, ?string $locale = 'id_ID'): string
{
return Number::currency($value, $format, $locale, $precision);
return $currency.Number::format($value, locale: $locale);
}
}
@ -16,3 +16,10 @@ function replaceCurrency(string $value)
return (int) Str::replace('.', '', $value);
}
}
if (! function_exists('percentage')) {
function percentage(int|float $value, int $precision = 2, int $maxPrecision = 2, ?string $locale = 'id_ID'): string
{
return Number::percentage($value, $precision, $maxPrecision, $locale);
}
}