'integer', 'zfw' => 'float', 'active' => 'boolean', ]; /** * Validation rules * * @var array */ public static $rules = [ 'subfleet_id' => 'required', 'name' => 'required', ]; /** * Callbacks */ protected static function boot() { parent::boot(); static::creating(function (Aircraft $model) { if (!empty($model->icao)) { $model->icao = strtoupper(trim($model->icao)); } if(empty($model->hex_code)) { $model->hex_code = ICAO::createHexCode(); } }); } /** * foreign keys */ public function airport() { return $this->belongsTo(Airport::class, 'airport_id'); } public function subfleet() { return $this->belongsTo(Subfleet::class, 'subfleet_id'); } }