php - How to create a validate class in laravel to call multiple form submission controllers?
过去多啦不再A梦
过去多啦不再A梦 2017-07-06 10:34:45
0
2
1089

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

过去多啦不再A梦
过去多啦不再A梦

reply all(2)
学习ing

Use Form Request

  1. In this, cross-check which form elements exist, and then only apply the rules for existing elements.

  2. Wherever this verification is needed, just inject it.

学霸
php artisan make:request DemoRequest

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.

public function store(Requests\DemoRequest $request)
    {
        $input = $request->all();
        //....
     }   
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template