'date', 'price' => 'decimal:4', ]; public static function current(): ?float { $latestPrice = static::latest('date')->first(); return $latestPrice ? $latestPrice->price : null; } public static function forDate(string $date): ?float { $price = static::where('date', '<=', $date) ->orderBy('date', 'desc') ->first(); return $price ? $price->price : null; } public static function updatePrice(string $date, float $price): self { return static::updateOrCreate( ['date' => $date], ['price' => $price] ); } public static function history(int $limit = 30): Collection { return static::orderBy('date', 'desc')->limit($limit)->get(); } }