<?php

namespace App\Http\Requests\Labor;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'labor_number' => ['sometimes', 'required', 'string', 'max:50'],
            'category' => ['sometimes', 'required', 'string', 'in:가로,세로할증'],
            'min_m' => ['sometimes', 'required', 'numeric', 'min:0', 'max:9999.99'],
            'max_m' => ['sometimes', 'required', 'numeric', 'min:0', 'max:9999.99', 'gte:min_m'],
            'labor_price' => ['nullable', 'integer', 'min:0'],
            'status' => ['sometimes', 'required', 'string', 'in:사용,중지'],
        ];
    }

    public function messages(): array
    {
        return [
            'labor_number.required' => __('validation.required', ['attribute' => '노임번호']),
            'category.required' => __('validation.required', ['attribute' => '구분']),
            'category.in' => __('validation.in', ['attribute' => '구분']),
            'min_m.required' => __('validation.required', ['attribute' => '최소(m)']),
            'max_m.required' => __('validation.required', ['attribute' => '최대(m)']),
            'max_m.gte' => __('validation.gte.numeric', ['attribute' => '최대(m)', 'value' => '최소(m)']),
            'status.required' => __('validation.required', ['attribute' => '상태']),
            'status.in' => __('validation.in', ['attribute' => '상태']),
        ];
    }
}
