In some page I have an input that I need to match against some query result and make sure that the input from the user is not greater than the result of the DB query (I will do SUM of some column).
For such validation rule, what should I use in the Form Request? Should I create a new rule and call it something like ValidCustomInputRule
and do the DB query there, or there is a better option for that inside the Form Request?
2
Answers
You can create a custom validation rule in the Form Request and perform the DB query in the rule itself.
You can create a custom validation rule and use it in rules
You can use php artisan make:rule ValidCustomInputRule to make it
I think you can use a Closure if you want to keep it all inside your form request.
If that doesn’t work, I think you can add it to the
after
hook.