<?php

namespace App\Http\Requests\Qms;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'categories' => 'sometimes|array|min:1',
            'categories.*.id' => 'nullable|integer|exists:audit_checklist_categories,id',
            'categories.*.title' => 'required|string|max:200',
            'categories.*.sort_order' => 'nullable|integer|min:0',
            'categories.*.items' => 'required|array|min:1',
            'categories.*.items.*.id' => 'nullable|integer|exists:audit_checklist_items,id',
            'categories.*.items.*.name' => 'required|string|max:200',
            'categories.*.items.*.description' => 'nullable|string',
            'categories.*.items.*.sort_order' => 'nullable|integer|min:0',
        ];
    }
}
