'required', ]; protected $casts = [ 'source' => 'integer', ]; /** * When setting the name attribute, also set the slug * * @return Attribute */ public function name(): Attribute { return Attribute::make( set: fn ($name) => [ 'name' => $name, 'slug' => str_slug($name), ] ); } /** * If it was filled in from ACARS, then it's read only * * @return bool */ public function readOnly(): Attribute { return Attribute::make( get: fn ($_, $attrs) => $this->source === PirepFieldSource::ACARS ); } /** * Foreign Keys */ public function pirep() { return $this->belongsTo(Pirep::class, 'pirep_id'); } }