Have a clean controller and shift your entire validation and authorization logic to a separate class using Laravel’s Form request class.
Validations with Laravel has always been a very easy thing to do. A lot of available rules works like charm. Now all these rules can sometime be overwhelming inside the controller. So, in this tutorial, I will show you how to create a Request class and handle the validations and the authorization rules as well inside a different class.
The basic idea is, create a new Request class where we will write our validation rules and also we can write our authorize logic. And then pass that Request class to the controller.
This way, we don’t have to write the authorization rules and validation rules inside the controller and hence our controller will be leaner and cleaner.