toDateString(); } return $date_string; }; $request->hostname = config('api.url'); $gadaian = Http::get($request->hostname . '/api/reports/gadaian', [ 'startDate' => $getReportDate($request->startDate), 'endDate' => $getReportDate($request->endDate), ])->json(); $startDate = $getReportDate($request->startDate); $endDate = $getReportDate($request->endDate); return view('reports.gadaian.index', compact('gadaian', 'startDate', 'endDate')); } public function downloadGadaianCawanganExcel(Request $request) { $api_url = $request->hostname; $auth_user = Auth::user(); $current = Carbon::now(); $current = new Carbon(); $tarikh_cetak = $current->toDateString(); $getReportDate = function ($date_string) use ($current) { if ($date_string == null) { return $current->toDateString(); } return $date_string; }; $request->hostname = config('api.url'); $kod_cawangan = $request->kod_cawangan; $data = Http::get($request->hostname . '/api/reports/gadaian/' . $kod_cawangan, [ 'startDate' => $getReportDate($request->startDate), 'endDate' => $getReportDate($request->endDate), ])->json(); $file_title = sprintf("LaporanGadaian %s (%s - %s).xlsx", $kod_cawangan, $request->startDate, $request->endDate); return Excel::download(new GadaianExport($data), $file_title); } }