Files
FlightsAPI/app/Models/Airport.php
T

39 lines
817 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Airport extends Model
{
protected $fillable = [
'type',
'name',
'latitude_deg',
'longitude_deg',
'elevation_ft',
'timezone',
'region_id',
'municipality',
'icao_code',
'iata_code',
'local_code',
];
protected $casts = [
'latitude_deg' => 'float',
'longitude_deg' => 'float',
'elevation_ft' => 'integer',
];
public function displayName() : string{
return "{$this->municipality} / {$this->name} ({$this->iata_code}/{$this->icao_code})";
}
public function region(): BelongsTo
{
return $this->belongsTo(Region::class);
}
}