<?php

namespace App\Http\Requests\Batches;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'tank_id' => ['sometimes', 'required', 'integer', 'exists:tanks,id'],
            'code' => ['sometimes', 'required', 'string', 'max:255'],
            'fish_count_initial' => ['sometimes', 'required', 'integer', 'min:0'],
            'fish_count_current' => ['sometimes', 'required', 'integer', 'min:0'],
            'avg_weight_initial_g' => ['sometimes', 'required', 'integer', 'min:0'],
            'avg_weight_current_g' => ['sometimes', 'required', 'integer', 'min:0'],
            'status' => ['sometimes', 'required', 'string', 'in:active,closing,closed'],
            'feeding_plan_snapshot' => ['sometimes', 'nullable', 'array'],
            'feeding_plan_snapshot.meals_per_day' => ['sometimes', 'nullable', 'integer', 'min:1', 'max:5'],
            'feeding_plan_snapshot.feeding_times' => ['sometimes', 'nullable', 'array'],
            'feeding_plan_snapshot.feeding_times.*' => ['sometimes', 'nullable', 'string', 'max:10'],
            'feeding_plan_snapshot.start_mode' => ['sometimes', 'nullable', 'string', 'in:alevines,por_peso'],
            'batch_plan_history' => ['sometimes', 'nullable', 'array'],
            'costs_accumulated_crc' => ['sometimes', 'nullable', 'integer', 'min:0'],
            'revenue_crc' => ['sometimes', 'nullable', 'integer', 'min:0'],
            'notes' => ['sometimes', 'nullable', 'string'],
            'started_at' => ['sometimes', 'required', 'date'],
            'ended_at' => ['sometimes', 'nullable', 'date'],
        ];
    }
}
