<?php

namespace App\Http\Requests\WorkOrder;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'inputs' => 'required|array|min:1',
            'inputs.*.stock_lot_id' => 'required|integer',
            'inputs.*.qty' => 'required|numeric|gt:0',
            'inputs.*.bom_group_key' => 'sometimes|nullable|string|max:100',
            'replace' => 'sometimes|boolean',
        ];
    }

    public function messages(): array
    {
        return [
            'inputs.required' => __('error.validation.required', ['attribute' => '투입 목록']),
            'inputs.*.stock_lot_id.required' => __('error.validation.required', ['attribute' => 'LOT ID']),
            'inputs.*.qty.required' => __('error.validation.required', ['attribute' => '수량']),
            'inputs.*.qty.gt' => __('error.validation.gt', ['attribute' => '수량', 'value' => 0]),
        ];
    }
}
