45 lines
1006 B
PHP
45 lines
1006 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class WeatherReport extends Model
|
|
{
|
|
/** @use HasFactory<\Database\Factories\WeatherReportFactory> */
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'type',
|
|
'reported_at',
|
|
'generated_at',
|
|
'latitude',
|
|
'longitude',
|
|
'elevation_meters',
|
|
];
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'reported_at' => 'datetime',
|
|
'generated_at' => 'datetime',
|
|
'latitude' => 'decimal:7',
|
|
'longitude' => 'decimal:7',
|
|
'elevation_meters' => 'decimal:4',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return HasMany<WeatherPeriod, $this>
|
|
*/
|
|
public function periods(): HasMany
|
|
{
|
|
return $this->hasMany(WeatherPeriod::class)->orderBy('period_number');
|
|
}
|
|
}
|