// ============================================================ // ADD this method inside ReportsController (paste before the // final closing brace). It powers /reports/disposals. // ProbationCase is already imported in ReportsController. // ============================================================ /** Disposal-outcome report — counts by disposal method + source split (req 6.x). */ public function disposals(\Illuminate\Http\Request $request) { $base = fn () => \App\Models\ProbationCase::forCurrentBranch(); $labels = config('probation.disposals', []); $counts = $base()->whereNotNull('disposal_method') ->selectRaw('disposal_method, COUNT(*) c')->groupBy('disposal_method') ->pluck('c', 'disposal_method')->toArray(); $total = array_sum($counts); $notFinalized = $base()->whereNull('disposal_method')->count(); $bySource = $base()->selectRaw('source_type, COUNT(*) c')->groupBy('source_type') ->pluck('c', 'source_type')->toArray(); $fines = (float) $base()->where('disposal_method', 'fined')->sum('fine_amount'); return view('reports.disposals', compact('labels', 'counts', 'total', 'notFinalized', 'bySource', 'fines')); }