<?php

namespace App\Http\Requests\Api;

use App\Libs\Security\XSSCleanFilter;
use Illuminate\Foundation\Http\FormRequest;
use App\Libs\Support\Sanitizer\Traits\SanitizesInput;

class NumericShow extends FormRequest
{
    use SanitizesInput;
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'id' => 'bail|required|numeric'
        ];
    }

    public function filters() {
        return [
            'id' => "trim|strip_tags|xss_clean",
        ];
    }

    public function all($keys = null) {
        $data = parent::all();
        if($this->route()->hasParameters()) {
            $parameterName = $this->route()->parameterNames()[0];
            $data['id'] = $this->route()->parameter($parameterName);
        }
        return $data;
    }
}
