Phi*_*arc 4 php validation laravel
我正在使用Laravel 4.
我愿意显示一个文本,只有我的请求包含否 input
例如,我有一个产品列表mysite/products,我有一个输入字段按价格过滤,一旦点击就会显示以下网址:mysite/products?price=true
我可以if(Input::has('price'))用来检查我是否有这个输入,但问题是我有一堆输入字段,我想只在没有输入时显示文本.
我想的是:
@if(Input::has('price')||Input::has('mixed')||Input::has('male')||Input::has('female')||Input::has('kid')||Input::has('page'))
//Do nothing
@else
//Display my text here
@endif
Run Code Online (Sandbox Code Playgroud)
但是以简化的方式......
我正在考虑检查URi Request::segment(1)并查看它是否匹配,'products'但即使输入处于活动状态也是如此.
Jos*_*ber 10
获取所有输入数据,并计算:
@if ( ! count(Input::all()))
// Display text here
@endif
Run Code Online (Sandbox Code Playgroud)
@if (!request()->filled('price') || !request()->filled('mixed') || !request()->filled('male') || !request()->filled('female'))
// Display my text here
@endif
Run Code Online (Sandbox Code Playgroud)
Laravel 5.4 之前:
$request->exists:确定请求是否包含给定的输入项密钥。
$request->has:确定请求是否包含输入项的非空值。
在 Laravel 5.5 中:
$request->exists: $request->has 的别名$request->has:确定请求是否包含给定的输入项密钥。$request->filled:确定请求是否包含输入项的非空值。