get parameter validation in Laravel
大家讲道理
大家讲道理 2017-05-16 16:47:29
0
3
464

Could you please tell me how to verify the parameters passed by get in laravel

There are many filtering conditions at the top of the order list page, but these filtering conditions have certain rules. For example, the amount must be a number, and the user name cannot be greater than 5 digits.
If parameters are passed to the background through get for conditional filtering, the url address and How to verify that it is the same when no parameters are passed?

If verification is performed, if the user comes in without any filtering conditions at the beginning, the verification will fail directly

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(3)
迷茫

One solution is to add an area to display errors on the page and display it using the method provided by Laravel (submit the form directly, use js to verify whether the information is legal before submitting, submit after the js verification passes, and then verify it on the backend)

@if ($errors->count() > 0)
    {{ $errors->first($errors->keys()[0] ?? null) }}
@endif

However, this method is not very friendly. You can change the screening form submission to asynchronous, and use js to render the page results.

阿神

Parameter filtering rules?
Use middleware decisively, get the get parameter request, $request->getQueryString(), and then put it in the middleware for screening.

PHPzhong

Don’t verify the format if there are no parameters passed in.
Verify only after passing the parameters.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!