<?php

namespace Functional\Tracking\Models;

use Functional\Tracking\Database\Factories\BodyMetricFactory;
use Functional\Users\Models\User;
use Illuminate\Database\Eloquent\Attributes\UseFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
 * Mensuration ponctuelle d'un utilisateur (poids, masse grasse) à une date donnée.
 */
#[UseFactory(BodyMetricFactory::class)]
class BodyMetric extends Model
{
    use HasFactory;

    protected $fillable = [
        'user_id', 'measured_on', 'weight', 'body_fat', 'notes',
    ];

    protected $casts = [
        'measured_on' => 'date',
        'weight' => 'decimal:2',
        'body_fat' => 'decimal:2',
    ];

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