<?php

declare(strict_types=1);

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

final class ArtworkMaturityAuditFinding extends Model
{
    use HasFactory;

    public const STATUS_OPEN = 'open';
    public const STATUS_REVIEWED = 'reviewed';
    public const STATUS_CLEARED = 'cleared';

    protected $fillable = [
        'artwork_id',
        'status',
        'thumbnail_variant',
        'ai_label',
        'ai_confidence',
        'ai_score',
        'ai_labels',
        'ai_model',
        'ai_threshold_used',
        'ai_analysis_time_ms',
        'ai_action_hint',
        'ai_status',
        'ai_advisory',
        'detected_at',
        'last_scanned_at',
        'resolution_action',
        'resolution_note',
        'resolved_by',
        'resolved_at',
    ];

    protected $casts = [
        'ai_confidence' => 'float',
        'ai_score' => 'float',
        'ai_labels' => 'array',
        'ai_threshold_used' => 'float',
        'ai_analysis_time_ms' => 'integer',
        'detected_at' => 'datetime',
        'last_scanned_at' => 'datetime',
        'resolved_at' => 'datetime',
    ];

    public function artwork(): BelongsTo
    {
        return $this->belongsTo(Artwork::class);
    }

    public function resolver(): BelongsTo
    {
        return $this->belongsTo(User::class, 'resolved_by');
    }
}