I'm working on an endpoint that filters with input a list of resources.
For example, if my input is "key", it can retrieve:
keyboard
KeyBoard
red key
key of pc
but, if my input is "key " <- with white space, I have to use complete input, and not trim, and the result:
key of pc
So, the endpoint was made in Laravel, but when I try to get the query param or input, I get the data trimmed.
...
public function __invoke(CustomRequest $request)
{
dd($request->query('search')); // prints "key" and not "key "
...
}
And CustomRequest is:
class CustomRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules(): array
{
return [
'search' => ['sometimes', 'nullable', 'string'],
];
}
}