*/ use HasFactory; use HasTranslations; /** * The attributes that are mass assignable. * * @var list */ protected $fillable = [ 'name', 'url', 'is_archived', 'gitlab_id', ]; /** * The translatable columns. * * @var list */ public $translatable = [ 'name', ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'is_archived' => 'boolean', ]; /** * Perform any actions required after the model boots. * * @return void */ protected static function booted(): void { static::creating(function (self $model) { self::manageFields($model); }); static::updating(function (self $model) { self::manageFields($model); }); } // * METHODS. /** * Manage model fields. * * @param self $model * @return void */ private static function manageFields(self $model): void { TranslationHelper::assertTranslationFieldIsUnique($model, $model->name, 'name'); TranslationHelper::validateFallbackTranslations($model); } }