72 lines
2.1 KiB
PHP
72 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Aircraft extends Model
|
|
{
|
|
protected $fillable = [
|
|
'designator',
|
|
'manufacturer_code',
|
|
'model_full_name',
|
|
'aircraft_description',
|
|
'engine_type',
|
|
'engine_count',
|
|
'wtc',
|
|
];
|
|
|
|
protected $casts = [
|
|
'engine_count' => 'integer',
|
|
];
|
|
|
|
protected $appends = [
|
|
'display_name',
|
|
'display_name_short'
|
|
];
|
|
|
|
public const array BOEING_FAMILIES = [
|
|
'707' => ['B701', 'B703', 'B720'],
|
|
'717' => ['B712', 'B717'],
|
|
'727' => ['B721', 'B722', 'B727'],
|
|
'737' => ['B731', 'B732', 'B733', 'B734', 'B735', 'B736', 'B737', 'B738', 'B739', 'B37M', 'B38M', 'B39M'],
|
|
'747' => ['B741', 'B742', 'B743', 'B744', 'B748', 'B74D', 'B74R', 'B74S'],
|
|
'757' => ['B752', 'B753', 'B757'],
|
|
'767' => ['B762', 'B763', 'B764', 'B767'],
|
|
'777' => ['B772', 'B773', 'B77L', 'B77W', 'B778', 'B779'],
|
|
'787' => ['B788', 'B789', 'B78X'],
|
|
];
|
|
|
|
public const array AIRBUS_FAMILIES = [
|
|
'A300' => ['A30B', 'A300', 'A306'],
|
|
'A310' => ['A310', 'A312', 'A313'],
|
|
'A318' => ['A318'],
|
|
'A319' => ['A319', 'A31X'],
|
|
'A320' => ['A320', 'A20N'],
|
|
'A321' => ['A321', 'A21N'],
|
|
'A330' => ['A330', 'A332', 'A333', 'A338', 'A339'],
|
|
'A340' => ['A340', 'A342', 'A343', 'A345', 'A346'],
|
|
'A350' => ['A350', 'A358', 'A359', 'A35K'],
|
|
'A380' => ['A380', 'A388'],
|
|
];
|
|
|
|
protected function displayName() : Attribute{
|
|
return Attribute::make(
|
|
get: function () {
|
|
return "{$this->manufacturer_code} {$this->model_full_name} ({$this->designator})";
|
|
}
|
|
);
|
|
}
|
|
|
|
protected function displayNameShort(): Attribute
|
|
{
|
|
return Attribute::make(
|
|
get: function () {
|
|
$name = "{$this->manufacturer_code} {$this->model_full_name}";
|
|
return trim(preg_replace('/\s*\(.*?\)/', '', $name));
|
|
}
|
|
);
|
|
}
|
|
}
|