<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Prunable;

class AiHealingLog extends Model
{
    use \Illuminate\Database\Eloquent\Factories\HasFactory, Prunable;

    protected $fillable = [
        'error_type',
        'error_message',
        'stack_trace',
        'ai_diagnosis',
        'original_code',
        'fixed_code',
        'action_taken',
        'status',
    ];

    protected $casts = [
        'stack_trace' => 'encrypted',
        'original_code' => 'encrypted',
        'fixed_code' => 'encrypted',
    ];

    public function prunable(): Builder
    {
        return self::query()->where('created_at', '<=', now()->subDays(90));
    }
}
