这将显示当前的url页面,我想从视图页面中过滤内容...任何想法如何在控制器中执行?
此处学生是当前查看页面
我在哪里弄错了?我的表格的字段是姓名,国家,年龄。
<form method='get' style="display:inline-block;width: 260px;" action='{{Request::url()}}'>
<div class="input-group">
<input type="text" name="q" value="{{ Request::get('q') }}" class="form-control input-sm pull-{{ trans('crudbooster.right') }}" placeholder="{{trans('crudbooster.filter_search')}}"/>
{!! CRUDBooster::getUrlParameters(['q']) !!}
<div class="input-group-btn">
@if(Request::get('q'))
<?php
$parameters = Request::all();
unset($parameters['q']);
$build_query = urldecode(http_build_query($parameters));
$build_query = ($build_query)?"?".$build_query:"";
$build_query = (Request::all())?$build_query:"";
?>
<button type='button' onclick='location.href="{{ CRUDBooster::mainpath().$build_query}}"' title="{{trans('crudbooster.button_reset')}}" class='btn btn-sm btn-warning'><i class='fa fa-ban'></i></button>
@endif
<button type='submit' class="btn btn-sm btn-default"><i class="fa fa-search"></i></button>
</div>
</div>
</form>
这是我的控制器代码。
public function getstudents(Request $request)
{
$students =DB::table('users')
->orderBy('created_at',desc)
->get();
$searchby =$request->get('q');
$students = DB::table('students')
->where('name', 'like', '%' . $searchby . '%')
->get();
return view('students',compact('students'));
}