I have about 50 input fields and they are all required. Is there a easy way to check if they are all set? So i don't have to manually put every field in my model with a validation rule of "required"?
I know this is late, but I wrote a simple function to solve this problem for myself
foreach ($request->except('_token') as $data => $value) {
$valids[$data] = "required";
}
$request->validate($valids);
Good luck!
You can use the code below. This worked for me to make all request fields required.
$request->validate([
'*' => 'required',
]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With