<?php

namespace App\Http\Requests;

use App\Support\Backoffice\Sanitizer\Traits\SanitizesInput;
use Illuminate\Foundation\Http\FormRequest;

class BasicListingRequest extends FormRequest
{
    use SanitizesInput;

    /**
     * Get Values From input
     *
     * @return array
     */
    public function validationData(): array
    {
        return [
            'page' => $this->input('perPage', 1),
            'itemsPerPage' => $this->input('itemsPerPage', 25),
            'search' => $this->input('search', null),
        ];
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules(): array
    {
        return [
            'page' => 'nullable|integer',
            'itemsPerPage' => 'nullable|integer|max:100',
            'search' => 'nullable|string',
        ];
    }

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