I was going through some of my morning feeds and there was a question on where validation should be done. In Laravel you have three good options to choice from. You can do your validation in your controller, in the model or in Form Requests. The things I hate most about doing the validation in the controller is the consistency in the rules I write. So in one post someone did a simple thing in their model. They simply added a static property to their models that had their rule set. It was simple and at the time time, I somehow missed it as an option. So if you don’t want to use the Form Request or do any validating in the model, you can add the ruleset property to your model to keep it consistent across your controller.

Leave a Reply

Post Navigation