<?php

namespace App\Modules\Platform\Lookup\Requests;

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

class LookupSearchRequest extends FormRequest
{
    /** @var list<string> */
    public const TYPES = [
        'departments',
        'positions',
        'employment_statuses',
        'countries',
        'regions',
        'cities',
        'employees',
        'warehouses',
        'categories',
        'items',
        'shifts',
        'leave_types',
        'candidates',
        'candidate_cvs',
        'job_requests',
        'vacancies',
        'applications',
        'interviews',
        'users',
        'offer_letters',
        'branches',
        'sections',
        'teams',
        'job_grades',
        'work_locations',
        'cost_centers',
        'salary_structures',
    ];

    public function authorize(): bool
    {
        return $this->user() !== null;
    }

    /**
     * @return array<string, mixed>
     */
    public function rules(): array
    {
        return [
            'type' => ['required', 'string', Rule::in(self::TYPES)],
            'q' => ['nullable', 'string', 'max:120'],
            'limit' => ['nullable', 'integer', 'min:5', 'max:50'],
            'selected' => ['nullable', 'integer', 'min:1'],
            'exclude' => ['nullable', 'integer', 'min:1'],
            'parent' => ['nullable', 'integer', 'min:1'],
        ];
    }
}
