Adds `label()` methods to TrendDirection and PredictionSource enums for cleaner display. Fixes mixed tab/space indentation in StatsOverviewWidget. Links all stats cards to their respective Filament resources (searches, stations, oil-predictions, api-logs). Documents BrentPriceChartWidget's manual registration.
44 lines
1.2 KiB
PHP
44 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Widgets;
|
|
|
|
use App\Models\BrentPrice;
|
|
use Filament\Widgets\ChartWidget;
|
|
|
|
class BrentPriceChartWidget extends ChartWidget
|
|
{
|
|
protected ?string $heading = 'Brent Crude — Last 30 Days (USD/barrel)';
|
|
|
|
protected ?string $pollingInterval = null;
|
|
|
|
/** Registered manually in AdminPanelProvider — excluded from auto-discovery to control placement. */
|
|
protected static bool $isDiscovered = false;
|
|
|
|
protected function getData(): array
|
|
{
|
|
$prices = BrentPrice::orderBy('date')
|
|
->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';
|
|
}
|
|
}
|