'boolean', 'order' => 'integer', ]; /** * Scope to get only active rules. */ public function scopeActive($query) { return $query->where('active', true); } /** * Get all active rules as a formatted text block for the system prompt. * * Returns an empty string when no active rule exists, so the prompt * stays clean and the AI behaves as before. */ public static function getFormattedRules(): string { $rules = self::active()->orderBy('order')->orderBy('id')->get(); if ($rules->isEmpty()) { return ''; } $output = ''; foreach ($rules as $rule) { $output .= "- **{$rule->title}**: {$rule->content}\n"; } return trim($output); } }