pembiayaanService = $pembiayaanService; $this->middleware(['auth', 'verified']); } /** * Show the application dashboard. * * @return \Illuminate\View\View */ public function index(Request $request) { $pembiayaan = $this->pembiayaanService->getPembiayaan($request->filter); $authUser = Auth::user(); $customerInfo = Http::withOptions(['verify' => config('app.api_verify')]) ->get(config('api.url') . '/portal/customer/info', ['ic' => $authUser['icno']]) ->json(); ['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)); $sixMonths = sizeOf(array_filter($customer_gadai, fn($x) => $x['tempoh'] >= 6)); $bilanganLelong = sizeOf($customer_lelong); $bilangan = sizeof($customer_gadai) + sizeOf($customer_lelong); return view('includes.home', compact('bilangan', 'sixMonths', 'total', 'bilanganLelong', 'pembiayaan')); } }