<?php

namespace App\Http\Requests\Backoffice;

use Elegant\Sanitizer\Laravel\SanitizesInput;
use Illuminate\Foundation\Http\FormRequest;

class AdminContentAutoComplete extends FormRequest
{
    use SanitizesInput;

    public function validationData(): array
    {
        return [
            'searchTerm' => $this->input('searchTerm'),
            'objectType' => $this->input('objectType'),
            'id' => $this->input('id')
        ];
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'searchTerm' => 'max:150',
            'objectType' => 'max:30',
            'id' => 'nullable|integer',
            'objectIds' => 'nullable|array',
            'objectIds.*' => 'integer',
        ];
    }

    /**
     * Filters to be applied to the input.
     *
     * @return array
     */
    public function filters()
    {
        return [
            'searchTerm' => "strip_tags|trim",
            'objectType' => "strip_tags|trim",
        ];
    }
}
