<?php

namespace App\Http\Requests;

use App\Models\Cattle;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class DeactivateCattleRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'reason' => ['required', Rule::in([Cattle::STATUS_SOLD, Cattle::STATUS_DEAD, Cattle::STATUS_CONSUMED])],
            'exit_weight_kg' => ['required', 'numeric', 'min:0.01', 'max:9999'],
            'death_cause' => ['required_if:reason,dead', 'nullable', 'string', 'max:255'],
            'price_per_kg' => ['nullable', 'numeric', 'min:0'],
            'total_price' => ['nullable', 'numeric', 'min:0'],
            'sale_date' => ['nullable', 'date'],
            'notes' => ['nullable', 'string', 'max:500'],
        ];
    }
}
