map(fn ($n) => now()->subMonths($n)); $values = $months->map(function ($m) { return (float) Subscription::where('status', 'paid') ->whereYear('paid_at', $m->year) ->whereMonth('paid_at', $m->month) ->sum('amount'); }); return [ 'datasets' => [ [ 'label' => 'MRR (MDL)', 'data' => $values->toArray(), 'backgroundColor' => 'rgba(34, 197, 94, 0.15)', 'borderColor' => '#22c55e', 'tension' => 0.35, 'fill' => true, ], ], 'labels' => $months->map(fn ($m) => $m->format('M Y'))->toArray(), ]; } protected function getType(): string { return 'line'; } }