<?php

namespace App\Http\Requests\ItemMaster;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'parent_type' => 'required|string|in:page,section',
            'parent_id' => 'required|integer|min:1',
            'ordered_items' => 'required|array|min:1',
            'ordered_items.*.child_type' => 'required|string|in:section,field,bom',
            'ordered_items.*.child_id' => 'required|integer|min:1',
        ];
    }

    public function messages(): array
    {
        return [
            'parent_type.required' => __('validation.required', ['attribute' => '부모 타입']),
            'parent_type.in' => __('validation.in', ['attribute' => '부모 타입']),
            'parent_id.required' => __('validation.required', ['attribute' => '부모 ID']),
            'ordered_items.required' => __('validation.required', ['attribute' => '정렬 항목']),
            'ordered_items.array' => __('validation.array', ['attribute' => '정렬 항목']),
        ];
    }
}
