<?php

namespace App\Http\Requests\Localization;

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

class StateRequest extends FormRequest
{
    use SanitizesInput;

    public function authorize()
    {
        return true;
    }

    public function rules()
    {
        return [
            'page' => 'nullable|integer',
            'itemsPerPage' => 'nullable|integer|max:100',
            'filter' => 'nullable|array',
            'filter.code' => 'nullable|string|max:20',
            'filter.name' => 'nullable|string|max:100',
            'filter.countryId' => 'nullable|int|exists:countries,id',
        ];
    }

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