<?php

namespace App\Http\Requests\Labor;

use App\Http\Requests\Traits\HasPagination;
use Illuminate\Foundation\Http\FormRequest;

class LaborIndexRequest extends FormRequest
{
    use HasPagination;

    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'search' => ['nullable', 'string', 'max:100'],
            'category' => ['nullable', 'string', 'in:가로,세로할증'],
            'status' => ['nullable', 'string', 'in:사용,중지'],
            'start_date' => ['nullable', 'date'],
            'end_date' => ['nullable', 'date', 'after_or_equal:start_date'],
            'page' => ['nullable', 'integer', 'min:1'],
            'per_page' => ['nullable', 'integer', 'min:1'],
            'sort_by' => ['nullable', 'string', 'in:created_at,labor_number,category,min_m,max_m,labor_price'],
            'sort_dir' => ['nullable', 'string', 'in:asc,desc'],
        ];
    }

    public function messages(): array
    {
        return [
            'category.in' => __('validation.in', ['attribute' => '구분']),
            'status.in' => __('validation.in', ['attribute' => '상태']),
            'end_date.after_or_equal' => __('validation.after_or_equal', ['attribute' => '종료일', 'date' => '시작일']),
        ];
    }
}
