<?php

namespace App\Models;

use App\Models\Concerns\BelongsToOwner;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class AssessmentScore extends Model
{
    use BelongsToOwner;

    protected $table = 'care_assessment_scores';

    protected $fillable = [
        'owner_ref', 'assessment_id', 'template_code',
        'total_score', 'max_score', 'subscores', 'severity_label', 'computed_at',
    ];

    protected function casts(): array
    {
        return [
            'total_score' => 'decimal:4',
            'max_score' => 'decimal:4',
            'subscores' => 'array',
            'computed_at' => 'datetime',
        ];
    }

    public function assessment(): BelongsTo
    {
        return $this->belongsTo(Assessment::class, 'assessment_id');
    }
}
