search

Home  >  Q&A  >  body text

php - How to create a validate class in laravel to call multiple form submission controllers?

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梦2746 days ago1126

reply all(2)I'll reply

  • 学习ing

    学习ing2017-07-06 10:36:45

    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.

    reply
    0
  • 欧阳克

    欧阳克2017-07-06 10:36:45

    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();
            //....
         }   

    reply
    0
  • Cancelreply