Answer the question
In order to leave comments, you need to log in
How do you filter input in Laravel?
Good morning.
I wonder if there are methods in Laravel that allow you to filter the input data? For example, Joomla has wonderful methods getInt (), getString (), etc., which allow you to get a variable with only the data that we ask for. And it doesn't matter if the user enters "abc", but the getInt() method will return zero to us in this case.
Actually, the question is, is there such a thing in Laravel, or can you recommend some similar and good package on github? I can write it myself, but the meaning, if it already exists and is actively used.
PS I'm learning Laravel, don't scold me, the question is really important :-)
Answer the question
In order to leave comments, you need to log in
There is a mechanism, and much more convenient and versatile:
https://laravel.com/docs/5.2/validation#form-reque...
I want to share the library I found for Laravel, which will help clean unwanted tags/attributes in strings: HTMLPurifier . I haven't tested it yet, but the number of downloads on packalyst inspires confidence.
We also conclude from some comments that it is not good to cast a string to a number where we expect a number, and it is necessary to validate the data (thanks Alexey Ukolov , I will take into account).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question