month; $currentYear = Carbon::now()->year; $countSuccess = Transaction::where('status', 'settlement') ->whereMonth('updated_at', $currentMonth) ->whereYear('updated_at', $currentYear) ->count(); $countPending = Transaction::where('status', 'pending') ->whereMonth('updated_at', $currentMonth) ->whereYear('updated_at', $currentYear) ->count(); $countCancelled = Transaction::where('status', 'cancel') ->whereMonth('updated_at', $currentMonth) ->whereYear('updated_at', $currentYear) ->count(); $countRefund = Transaction::where('status', 'refund') ->whereMonth('updated_at', $currentMonth) ->whereYear('updated_at', $currentYear) ->count(); $totalTransaction = Transaction::whereMonth('updated_at', $currentMonth) ->whereYear('updated_at', $currentYear) ->count(); $dataChartTransaction = []; $dataChartRefund = []; $totalRefund = Transaction::where('status', 'refund')->count(); $dataChartTotalRefund = []; $totalUser = User::where('status', 'Finished')->count(); $dataChartTotalUser = []; for ($bulan = 1; $bulan <= 12; $bulan++) { $transaction = Transaction::whereMonth('updated_at', $bulan) ->whereYear('updated_at', $currentYear) ->where('status', 'settlement') ->sum('total_bayar'); $refund = Transaction::whereMonth('updated_at', $bulan) ->whereYear('updated_at', $currentYear) ->where('status', 'partial refund') ->sum('total_harga'); $dataChartTransaction[] = intval($transaction); $dataChartRefund[] = intval($refund); } return view('admin.index', compact('transactions', 'countSuccess', 'countPending', 'countCancelled', 'countRefund', 'totalRefund', 'totalUser', 'totalTransaction', 'dataChartTransaction', 'dataChartRefund', 'dataChartTotalUser', 'dataChartTotalRefund')); } public function getChartByMonth() { $dataChartLaporan = []; $tahun = Carbon::now()->year; } public function getCharByYear() { } }