<?php

namespace App\Http\Requests\Batches;

use Illuminate\Foundation\Http\FormRequest;

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

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