feat(basicdata): tambahkan helper format_currency

- Menambahkan file helper `Currency.php` untuk format mata uang.
- Menyediakan fungsi `format_currency` yang mendukung parameter angka dan kode mata uang.
- Memperbarui `module.json` untuk memuat file helper secara otomatis.
This commit is contained in:
Daeng Deni Mardaeni
2025-04-27 19:08:41 +07:00
parent 7742df5d67
commit 9049075b0f
2 changed files with 15 additions and 1 deletions

12
app/Helpers/Currency.php Normal file
View File

@@ -0,0 +1,12 @@
<?php
use Modules\Basicdata\Models\Currency;
if(!function_exists('format_currency')) {
function format_currency($number, $currency = 'IDR') {
$currency = Currency::where('code', $currency)->first();
$symbol = $currency->symbol?? '';
return $symbol . ' ' . number_format($number, $currency->decimal_places, ',', '.');
}
}

View File

@@ -8,7 +8,9 @@
"providers": [
"Modules\\Basicdata\\Providers\\BasicdataServiceProvider"
],
"files": [],
"files": [
"app/Helpers/Currency.php"
],
"menu": {
"main": [],
"master": [