get('type', 'pertek'); $statuses = DashboardHelper::getStatusDataByType($type); if (empty($statuses)) { return response()->json([ 'success' => false, 'message' => 'Tipe izin tidak ditemukan.', ], 404); } $statuses = DashboardHelper::addTotalToStatuses($statuses); return response()->json([ 'success' => true, 'message' => 'Summary by status retrieved successfully.', 'type' => $type, 'type_label' => DashboardHelper::getTypeLabel($type), 'data' => $statuses, 'chart_data' => DashboardHelper::getChartData($type), 'last_updated' => now()->format('Y-m-d H:i:s'), ], 200); } catch (\Exception $e) { Log::error('Gagal mengambil summary status izin: ' . $e->getMessage()); return response()->json([ 'success' => false, 'message' => 'Terjadi kesalahan saat mengambil data.', 'error' => $e->getMessage(), ], 500); } } public function getAllSummary() { try { $allData = DashboardHelper::getAllStatistics(); return response()->json([ 'success' => true, 'message' => 'All summary data retrieved successfully.', 'data' => $allData, 'last_updated' => now()->format('Y-m-d H:i:s'), ], 200); } catch (\Exception $e) { Log::error('Gagal mengambil semua summary: ' . $e->getMessage()); return response()->json([ 'success' => false, 'message' => 'Terjadi kesalahan saat mengambil data.', 'error' => $e->getMessage(), ], 500); } } }