<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

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

    public function rules(): array
    {
        return [
            'ear_tag' => ['required', 'string', 'max:64', 'unique:cattle,ear_tag'],
            'ear_tag_type' => ['required', Rule::in(array_keys(config('ranch.ear_tag_types')))],
            'breed' => ['nullable', 'string', 'max:120'],
            'gender' => ['required', Rule::in(array_keys(config('ranch.genders')))],
            'birth_date' => ['nullable', 'date'],
            'mother_id' => ['nullable', 'integer', 'exists:cattle,id'],
            'pasture_id' => ['nullable', 'integer', 'exists:pastures,id'],
            'pasture_location' => ['nullable', 'string', 'max:120'],
            'notes' => ['nullable', 'string', 'max:2000'],
        ];
    }
}
