<?php

namespace App\Models;

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

class CattleSaleIncome extends Model
{
    use HasFactory;

    protected $fillable = [
        'cattle_id',
        'sale_date',
        'exit_weight_kg',
        'price_per_kg',
        'total_price',
        'notes',
        'user_id',
    ];

    protected $casts = [
        'sale_date' => 'date',
        'exit_weight_kg' => 'decimal:2',
        'price_per_kg' => 'decimal:2',
        'total_price' => 'decimal:2',
    ];

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

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