*/ use HasFactory; use HasTranslations; /** * The attributes that are mass assignable. * * @var list */ protected $fillable = [ "title", "url", "estimate_time", "spent_time", "is_closed", "gitlab_id", "gitlab_iid", "milestone_iid", "gitlab_project_id", "g_created_at", "g_updated_at", "g_closed_at", "g_due_date", ]; /** * The translatable columns. * * @var list */ public $translatable = [ "title", ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'is_closed' => '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->title, 'title'); TranslationHelper::validateFallbackTranslations($model); } }