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:
12
app/Helpers/Currency.php
Normal file
12
app/Helpers/Currency.php
Normal 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, ',', '.');
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,9 @@
|
||||
"providers": [
|
||||
"Modules\\Basicdata\\Providers\\BasicdataServiceProvider"
|
||||
],
|
||||
"files": [],
|
||||
"files": [
|
||||
"app/Helpers/Currency.php"
|
||||
],
|
||||
"menu": {
|
||||
"main": [],
|
||||
"master": [
|
||||
|
||||
Reference in New Issue
Block a user