- Add AdminPanelProvider mounting panel at `/admin` with `is_admin` auth guard - Add `is_admin` boolean column to users table - Add brent_prices and price_predictions tables with appropriate indexes - Add comprehensive admin design spec covering resources, dashboard, navigation, and build order - Configure default panel with amber primary color and standard middleware stack - Add compiled Filament assets (actions.js, app.css)
48 lines
1.4 KiB
PHP
48 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Services\OilPriceService;
|
|
use Illuminate\Console\Command;
|
|
use Throwable;
|
|
|
|
class PredictOilPrices extends Command
|
|
{
|
|
protected $signature = 'oil:predict {--fetch : Fetch latest FRED prices before predicting}';
|
|
|
|
protected $description = 'Generate a Brent crude oil price direction prediction';
|
|
|
|
public function handle(OilPriceService $service): int
|
|
{
|
|
try {
|
|
if ($this->option('fetch')) {
|
|
$this->info('Fetching latest Brent crude prices from FRED...');
|
|
$service->fetchBrentPrices();
|
|
}
|
|
|
|
$this->info('Generating prediction...');
|
|
$prediction = $service->generatePrediction();
|
|
|
|
if ($prediction === null) {
|
|
$this->error('Could not generate a prediction — not enough price data.');
|
|
|
|
return self::FAILURE;
|
|
}
|
|
|
|
$this->info(sprintf(
|
|
'Done. [%s] direction=%s confidence=%d%% — %s',
|
|
strtoupper($prediction->source->value),
|
|
$prediction->direction->value,
|
|
$prediction->confidence,
|
|
$prediction->reasoning,
|
|
));
|
|
} catch (Throwable $e) {
|
|
$this->error("Prediction failed: {$e->getMessage()}");
|
|
|
|
return self::FAILURE;
|
|
}
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|