*/ protected $fillable = [ 'life_event_category_id', 'label', 'label_translation_key', 'can_be_deleted', 'position', ]; /** * Get the life event category associated with the life event type. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\LifeEventCategory, $this> */ public function lifeEventCategory(): BelongsTo { return $this->belongsTo(LifeEventCategory::class); } /** * Get the life events associated with the life event type. * * @return \Illuminate\Database\Eloquent\Relations\HasMany<\App\Models\LifeEvent, $this> */ public function lifeEvents(): HasMany { return $this->hasMany(LifeEvent::class); } /** * Get the label attribute. * Life Event categories have a default label that can be translated. * Howerer, if a label is set, it will be used instead of the default. * * @return Attribute */ protected function label(): Attribute { return Attribute::make( get: function ($value, $attributes) { if (! $value) { return __($attributes['label_translation_key']); } return $value; }, set: fn ($value) => $value, ); } }