Answer the question
In order to leave comments, you need to log in
How to properly normalize query data?
I use my Request class in Laravel to implement the validation logic. Well, the question arose of how to pre-process the request data correctly. For example, put a phone number in a single format.
Should I write this logic in the constructor or somewhere else?
Answer the question
In order to leave comments, you need to log in
Just like it says in the documentation .
Upd. At the urgent request of the author, who does not know enemy dialects and does not plan to study them, I am writing in RUSSIAN:
out of the box, Laravel has middleware TrimStrings
and ConvertEmptyStringsToNull
, which modify the request data, normalizing them. Therefore, by analogy, you can create a mildware that normalizes the phone specifically and connects it to the routes you need.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question