<?php

namespace App\Models;

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

class WeightRecord extends Model
{
    use HasFactory;

    protected $fillable = [
        'cattle_id',
        'weight_kg',
        'weighed_at',
        'weight_gain_kg',
        'days_since_last',
        'daily_weight_gain',
        'notes',
        'user_id',
    ];

    protected $casts = [
        'weighed_at' => 'date',
        'weight_kg' => 'decimal:2',
        'weight_gain_kg' => 'decimal:2',
        'daily_weight_gain' => 'decimal:4',
    ];

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

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