<?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',
    ];

    protected function displayName() : Attribute{
        return Attribute::make(
            get: function () {
                return "{$this->manufacturer_code} {$this->model_full_name} ({$this->designator})";
            }
        );
    }
}
