Salam,
I think you can group them in one FormRequest and use the sometimes validation rule.
http://laravel.com/docs/4.2/validation#conditionally-adding-rules
'email' => 'sometimes|required|email',
'ID' => 'sometimes|required|integer',
etc...
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am creating a page that will search a database of students and return data on the student that matches it. I want to allow the user to search by different criteria such as bar-code, ID, email, etc.
My current approach is using a form for each search criteria as I only want the user to search by one criteria and not multiple, so I have a form to search for a bar-code, a form to search by ID and so on. Not one form with multiple fields and one submit button.
Of course I want rules on each form which will be different for each form, but it doesn't seem good practice to have a different method fire in the controller for each form and a Request for each form. So I'm trying to come up with a way to abstract the requests or rules for the request based on what form is fired but I'm coming up with nothing at the moment so I was hoping someone here could provide some guidance on how I could approach this in a better manner.
Thanks!
Please or to participate in this conversation.