我想从我的URL中检查数据是否有任何参数?我以前用过这个条件
@if(app('request')->input('type') || app('request')->input('type-2') || app('request')->input('type-3') || ... many more....)
<-- code here -->
@endif现在它有太多的参数。有没有最短的方法检查是否有任何参数?就像app('request')->has('input')这种最短的方式?请注意:laravel版本6.19
发布于 2020-06-06 17:58:03
Request::hasAny()应该解决您的问题:
@if (request()->hasAny('type', 'type-2', 'type-3'))它检查当前请求中是否存在任何给定的输入项键。您还可以使用Request::has来检查是否存在所有给定的输入项键。
要安全地检查当前请求中是否有任何输入,请使用Request::except()
@if (!empty(request()->except('_token', '_method')))https://stackoverflow.com/questions/62235751
复制相似问题