<?php

namespace App\Http\Requests\WorkResult;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'work_order_id' => 'sometimes|integer|exists:work_orders,id',
            'work_order_item_id' => 'nullable|integer|exists:work_order_items,id',
            'lot_no' => 'sometimes|string|max:50',
            'work_date' => 'sometimes|date',
            'process_type' => 'sometimes|in:screen,slat,bending',
            'product_name' => 'sometimes|string|max:200',
            'specification' => 'nullable|string|max:100',
            'production_qty' => 'sometimes|integer|min:0',
            'good_qty' => 'nullable|integer|min:0',
            'defect_qty' => 'sometimes|integer|min:0',
            'is_inspected' => 'nullable|boolean',
            'is_packaged' => 'nullable|boolean',
            'worker_id' => 'nullable|integer|exists:users,id',
            'memo' => 'nullable|string|max:2000',
        ];
    }

    public function messages(): array
    {
        return [
            'work_order_id.exists' => __('validation.exists', ['attribute' => '작업지시']),
            'lot_no.max' => __('validation.max.string', ['attribute' => '로트번호', 'max' => 50]),
            'work_date.date' => __('validation.date', ['attribute' => '작업일']),
            'product_name.max' => __('validation.max.string', ['attribute' => '품목명', 'max' => 200]),
        ];
    }
}
