我没什么问题。首先,如果用户未搜索任何内容,则需要使用分页显示$ projects的索引。第二,当我搜索某些分页不起作用时(空白)。
查看
{!! Form::open(['method'=>'get']) !!}
<input class="form-control" name="date" value="{{ request('date') }}" type="date"/>
<input class="form-control" name="search" value="{{ request('search') }}" type="text"/>
<div class="input-group-btn">
<button type="submit" class="btn btn-success">Хайх</button>
</div>
{!! Form::close() !!}
<table class="table table-hover table-bordered">
---------------
</table>
{{ $projects->links() }}
控制器
$search = $request->get('search');
$date = $request->get('date');
$projects = Project::where('title','like','%'.$search.'%')
->whereDate('created_at', $date)
->orderBy("created_at",'desc')
->paginate(10)
->withPath('?search=' . $search);
return view('projects.index', compact('projects'));
答案 0 :(得分:1)
您需要的小改动。
查看
{!! Form::open(['method'=>'get']) !!}
<input class="form-control" name="date" value="{{ request('date') }}" type="date"/>
<input class="form-control" name="search" value="{{ request('search') }}" type="text"/>
<div class="input-group-btn">
<button type="submit" class="btn btn-success">Хайх</button>
</div>
{!! Form::close() !!}
<table class="table table-hover table-bordered">
---------------
</table>
{{ $projects->appends(request()->query() }}
控制器
$search = $request->get('search');
$date = $request->get('date');
$projects = Project::where('title','like','%'.$search.'%')
->whereDate('created_at', $date)
->orderBy("created_at",'desc')
->paginate(10);
return view('projects.index', compact('projects'));