Menambahkan function formatTanggalIndonesia dan formatRupiah di Helper di Module LPJ

This commit is contained in:
2024-10-16 08:55:58 +07:00
parent 03c96af9c5
commit 8cfe31cb8b
2 changed files with 42 additions and 41 deletions

View File

@@ -1,8 +1,39 @@
<?php
function formatAlamat($alamat) {
return
($alamat->address ? $alamat->address . ', ' : '') .
use Carbon\Carbon;
function formatTanggalIndonesia($date)
{
$carbonDate = Carbon::parse($date);
$indonesianMonths = [
'Januari',
'Februari',
'Maret',
'April',
'Mei',
'Juni',
'Juli',
'Agustus',
'September',
'Oktober',
'November',
'Desember',
];
$month = $indonesianMonths[$carbonDate->month - 1];
return $carbonDate->format('d') . ' ' . $month . ' ' . $carbonDate->format('Y');
}
function formatRupiah($number)
{
$number = (float) $number;
return 'Rp ' . number_format($number, 2, ',', '.');
}
function formatAlamat($alamat)
{
return ($alamat->address ? $alamat->address . ', ' : '') .
(isset($alamat->village) ? $alamat->village->name . ', ' : '') .
(isset($alamat->city) ? $alamat->city->name . ', ' : '') .
(isset($alamat->province) ? $alamat->province->name . ', ' : '') .

View File

@@ -1,35 +1,3 @@
@php
function formatTanggalIndonesia($date)
{
$carbonDate = \Carbon\Carbon::parse($date);
$indonesianMonths = [
'Januari',
'Februari',
'Maret',
'April',
'Mei',
'Juni',
'Juli',
'Agustus',
'September',
'Oktober',
'November',
'Desember',
];
$month = $indonesianMonths[$carbonDate->month - 1];
return $carbonDate->format('d') . ' ' . $month . ' ' . $carbonDate->format('Y');
}
function formatRupiah($number)
{
// Convert to float if the input is a string
$number = (float) $number;
return 'Rp ' . number_format($number, 2, ',', '.');
}
@endphp
@extends('layouts.main')
@section('breadcrumbs')
@@ -199,4 +167,6 @@
</div>
</div>
</div>
</div>
</div>
@endsection