Filter out lelong that only have hargajualan that is null

This commit is contained in:
Afiq Hamzah
2024-07-19 10:03:04 +08:00
parent 8b40d30431
commit 29c1d42891
+3
View File
@@ -37,6 +37,9 @@ class HomeController extends Controller
['gadai' => $customer_gadai, 'lelong' => $customer_lelong] = $customerInfo;
// only get lelong that is harga jualan that is not null or 0
$customer_lelong = array_filter($customer_lelong, fn($x) => $x['hargajualan'] != null && $x['hargajualan'] != 0);
$formatMoney = fn($x) => number_format($x, 2);
$getTotal = fn($x) => array_reduce($x, fn($accumulator, $current_item) => $accumulator + $current_item['bakipjm'], 0);
$total = $formatMoney($getTotal($customer_gadai));