<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class RegisterLaundryScanRequest extends FormRequest
{
    /**
     * La autenticación la exige el middleware auth:sanctum (401 si falta token).
     */
    public function authorize(): bool
    {
        return true;
    }

    protected function prepareForValidation(): void
    {
        $this->merge([
            'operator_user_id' => $this->input('operatorUserId', $this->input('operator_user_id')),
        ]);
    }

    /**
     * @return array<string, array<int, string>>
     */
    public function rules(): array
    {
        return [
            'qr_or_folio' => ['required', 'string', 'max:65535'],
            'area_code' => ['required', 'string', 'max:64'],
            'operator_user_id' => ['nullable', 'integer', 'exists:users,id'],
        ];
    }
}
