How to create a validate class in laravel to call multiple form submission controllers?
I have a page with about 7 places that need to be verified, but in the controller I assigned a static page to each verification place.
The boss asked to write a validate class that includes these 7 places. validation rules, and then call them by passing parameters. . . I don't understand. . Please help me a lot
This is a validate rule. How to do it? Only call one of the validation rules
Use Form Request
In this, cross-check which form elements exist, and then only apply the rules for existing elements.
Wherever this verification is needed, just inject it.
You can generate a Request class for form verification. The file generated by this command is located in the app/Http/Requests/ folder. You can see that there are two methods in it: authorize() and rules() for form verification modifications. Just rules, and then reference DemoRequest when the controller initializes $request.