- BrentPriceFetcher owns ingestion (fetchFromEia / fetchFromFred, each throws on failure) - BrentPricePredictor owns prediction and marks latest brent_prices row as generated - oil:fetch command tries EIA, falls back to FRED, fails loudly if both fail - oil:predict command prompts if latest price already has a prediction; --force bypasses - add prediction_generated_at column to brent_prices - delete OilPriceService (replaced by the two focused services)
33 lines
728 B
PHP
33 lines
728 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Database\Factories\BrentPriceFactory;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
#[Fillable(['date', 'price_usd', 'prediction_generated_at'])]
|
|
class BrentPrice extends Model
|
|
{
|
|
/** @use HasFactory<BrentPriceFactory> */
|
|
use HasFactory;
|
|
|
|
public $timestamps = false;
|
|
|
|
protected $primaryKey = 'date';
|
|
|
|
public $incrementing = false;
|
|
|
|
protected $keyType = 'string';
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'date' => 'date',
|
|
'price_usd' => 'decimal:2',
|
|
'prediction_generated_at' => 'datetime',
|
|
];
|
|
}
|
|
}
|