getTotalLpjInternal($start_date, $end_date); $countLpjExternal = $this->getTotalLpjEksternal($start_date, $end_date); $countResume = $this->getResumeCabang($start_date, $end_date); return [ 'count_lpj_internal' => $countLpjInternal, 'count_lpj_eksternal' => $countLpjExternal, 'count_resume' => $countResume ]; } public function getTotalLpjInternal($start_date, $end_date) { $months = $this->getMonthly(); $regions = $this->getRegion(); $data = []; foreach ($months as $index => $month) { $monthNumber = $index + 1; $data[$month] = []; foreach ($regions as $region) { if ($monthNumber > now()->month) { $data[$month][$region] = [ 'total_laporan' => 0, 'total_debiture' => 0, ]; } else { $totalLaporan = Laporan::whereBetween('created_at', [$start_date, $end_date]) ->count(); $data[$month][$region] = [ 'total_laporan' => $totalLaporan, 'total_debiture' => 20, ]; } } } return $data; } public function getPendapatanAppraisal() { } public function getResumeCabang($start_date, $end_date) { $regions = $this->getRegion(); $status = ['batal', 'done']; $data = []; foreach ($status as $item) { $data[$item] = []; foreach ($regions as $region) { $totalLaporan = Laporan::where('created_at', '>=', $start_date)->where('created_at', '<=', $end_date)->count(); $data[$item][$region] = [ 'count_report' => $totalLaporan, ]; } } return $data; } public function getTotalLpjEksternal($start_date, $end_date) { $months = $this->getMonthly(); $data = []; foreach ($months as $index => $month) { $monthNumber = $index + 1; if ($monthNumber > now()->month) { $data[$month] = [ 'total_laporan' => 0, 'total_debiture' => 0, ]; } else { $totalLaporan = Laporan::where('created_at', '>=', $start_date)->where('created_at', '<=', $end_date)->count(); $data[$month] = [ 'total_laporan' => $totalLaporan, 'total_debiture' => 20, ]; } } return $data; } private function getMonthly() { return [ 'januari', 'februari', 'maret', 'april', 'mei', 'juni', 'juli', 'agustus', 'september', 'oktober', 'november', 'desember', ]; } private function getRegion() { return [ 'jabodetabek', 'non-jabodetabek', ]; } }