*/ #[\Override] protected $fillable = ['name']; // * EVENTS /** * Perform any actions required after the model boots. */ protected static function booted(): void { static::created(fn () => self::removeCached()); static::updated(fn () => self::removeCached()); static::deleting(function (self $model): void { if ($model->questions()->count()) { throw ValidationException::withMessages([ 'error' => // phpcs:ignore Generic.Files.LineLength.TooLong trans("Il n'est pas possible de supprimer ce theme car il est associƩ a des questions,\u{00A0} suppirmer les questions d'abord."), ]); } }); static::deleted(fn () => self::removeCached()); } // * RELATIONS /** * Question relation. * * @return HasMany */ public function questions(): HasMany { return $this->hasMany(FaqQuestion::class, 'theme_id'); } /** * Activities logs One-to-many relationship. * * @return HasMany */ public function activityLogs(): HasMany { return $this->hasMany(ActivityLog::class); } }