<?php

declare(strict_types=1);

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

/**
 * Валидация ручного маппинга неизвестных статусов воронки (§6.4 wizard).
 */
class ResolveUnknownStatusesRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user() !== null;
    }

    /**
     * @return array<string, mixed>
     */
    public function rules(): array
    {
        return [
            'mappings' => ['required', 'array', 'min:1'],
            'mappings.*.status_ru' => ['required', 'string', 'max:100'],
            'mappings.*.slug' => ['required', 'string', Rule::exists('lead_statuses', 'slug')],
        ];
    }
}
