Files
fuel-price/app/Filament/Widgets/BrentPriceChartWidget.php
Ovidiu U 4f57c97015
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (8.3) (push) Has been cancelled
tests / ci (8.4) (push) Has been cancelled
tests / ci (8.5) (push) Has been cancelled
docs: add comprehensive API reference documentation
Adds complete API reference (api-reference.md) covering all endpoints: /api/stations (nearby search with postcode/lat+lng), /api/stats/searches (aggregated search stats), /api/prediction (7-day price forecast with multi-signal breakdown), and auth routes (register/login/logout/me). Includes request/response examples, error shapes, fuel type aliases, and signal structure details. Also removes unused AccountWidget from admin panel, disables BrentPriceChartWidget discovery, and adds searches stat to StatsOverviewWidget.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-05 19:34:32 +01:00

43 lines
1.1 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;
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';
}
}