where('date', '>=', now()->subDays(30)->toDateString()) ->get(); return [ 'datasets' => [ [ 'label' => 'USD/barrel', 'data' => $prices->pluck('price_usd')->map(fn ($p) => (float) $p)->toArray(), 'borderColor' => '#f59e0b', 'fill' => false, 'tension' => 0.3, ], ], 'labels' => $prices->pluck('date') ->map(fn ($d) => $d->format('d M')) ->toArray(), ]; } protected function getType(): string { return 'line'; } }