<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'items' => 'required|array|min:1',
            'items.*.id' => 'required|integer|exists:positions,id',
            'items.*.sort_order' => 'required|integer|min:0',
        ];
    }

    public function messages(): array
    {
        return [
            'items.required' => __('validation.required', ['attribute' => '항목']),
            'items.*.id.required' => __('validation.required', ['attribute' => 'ID']),
            'items.*.id.exists' => __('validation.exists', ['attribute' => 'ID']),
            'items.*.sort_order.required' => __('validation.required', ['attribute' => '정렬순서']),
        ];
    }
}
