<?php

namespace App\Http\Requests\Api\V1\Production;

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

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

    public function rules(): array
    {
        $id = $this->route('id');

        return [
            'name' => 'sometimes|string|max:100',
            'size_code' => [
                'sometimes',
                'string',
                'max:10',
                Rule::unique('batch_size_configs', 'size_code')->ignore($id),
            ],
            'size_value' => 'sometimes|numeric|min:0.1|max:100',
            'size_unit' => 'sometimes|string|max:10',
            'scoops_per_batch' => 'sometimes|integer|min:1|max:500',
            'ingredient_multiplier' => 'sometimes|numeric|min:0.1|max:100',
            'default_expiry_hours' => 'sometimes|integer|min:1|max:168',
            'is_active' => 'sometimes|boolean',
        ];
    }
}
