whereNotNull('body_part') ->selectRaw('body_part, COUNT(*) as total') ->groupBy('body_part') ->orderByDesc('total') ->pluck('total', 'body_part'); return [ 'datasets' => [ [ 'data' => $countsByBodyPart->values()->all(), 'backgroundColor' => self::PALETTE, ], ], 'labels' => $countsByBodyPart->keys()->all(), ]; } protected function getType(): string { return 'doughnut'; } }