Answer the question
In order to leave comments, you need to log in
Where in Laravel is it better to validate incoming data - in the controller or make a custom Request for the controller, or Middleware?
subject :)
What approach will be the best in terms of OOP and everything else?
Or to take out in a separate service class?
Or something else?
How right?
Answer the question
In order to leave comments, you need to log in
Validation is usually what? Sheet) Therefore, your Form Request. Writing php artisan make:request and then importing into ide is literally seconds of time. But in this class you can do a lot of things. For example, prepareForValidation, messages, logic with its own rules, and all this will be in one place. Pushing validation into middleware or into your own classes in Laravel is a perversion.
In fact, Lara ALREADY has this very separate service - Illuminate\Http\Request , which is designed to validate incoming data.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question