<?php

namespace App\Models\Care;

use App\Models\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class HealthMetric extends Model
{
    const UPDATED_AT = null;

    protected $fillable = [
        'care_profile_id', 'metric_type', 'value', 'unit',
        'recorded_at', 'recorder_id', 'remark',
    ];

    protected function casts(): array
    {
        return [
            'value' => 'decimal:2',
            'recorded_at' => 'datetime',
        ];
    }

    public function profile(): BelongsTo
    {
        return $this->belongsTo(CareProfile::class, 'care_profile_id');
    }

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