- 控制器 ->paginate($this->paginate, [’*’], ‘自定义名称’);
- 页面
{!! $list->appends([‘自定义名称’ => $list->currentPage()])->render() !!}
或者
{{ $list->appends([‘自定义名称’ => $list->currentPage()])->links() }}
控制器:
public function list(){
$one_level_id = request()->input('oid');
$second_level_id = request()->input('sid');
$second_level = [];
$three_level = [];
$one_level = Districts::where('level',Districts::LEVEL_ONE)
->orderBy('created_at','asc')
->paginate($this->paginate, ['*'], 'one_level_page');
if($one_level_id) {
$second_level = Districts::where('level', Districts::LEVEL_SECOND)
->where('parent_id', $one_level_id)
->orderBy('created_at', 'asc')
->paginate($this->paginate, ['*'], 'second_level_page');
}
if($second_level_id) {
$three_level = Districts::where('level', Districts::LEVEL_THREE)
->where('parent_id', $second_level_id)
->orderBy('created_at', 'asc')
->paginate($this->paginate, ['*'], 'three_level_page');
}
return view('district.list',[
'one_level' => $one_level,
'second_level' => $second_level,
'three_level' => $three_level,
'oid' => $one_level_id,
'sid' => $second_level_id,
]);
}
页面:
<div class="layui-row layui-col-space10">
<div class="layui-col-md4 one-level">
<b>城市</b>
<table class="layui-table">
...
</table>
<div class="pull-right">
@if($one_level) {!! $one_level->appends(['oid'=>$oid,'sid'=>$sid,'one_level_page' => $one_level->currentPage()])->render() !!} @endif
或者
@if($one_level) {{ $one_level->appends(['oid'=>$oid,'sid'=>$sid,'one_level_page' => $one_level->currentPage()])->links() }} @endif
</div>
</div>
<div class="layui-col-md4 second-level">
<b>地区</b>
<table class="layui-table">
...
</table>
<div class="pull-right">
@if($second_level) {!! $second_level->appends(['oid'=>$oid,'sid'=>$sid,'second_level_page' => $second_level->currentPage()])->render() !!} @endif
或者
@if($second_level) {{ $second_level->appends(['oid'=>$oid,'sid'=>$sid,'second_level_page' => $second_level->currentPage()])->links() }} @endif
</div>
</div>
<div class="layui-col-md4 three-level">
<b>街道</b>
<table class="layui-table">
...
</table>
<div class="pull-right">
@if($three_level) {!! $three_level->appends(['oid'=>$oid,'sid'=>$sid,'three_level_page' => $three_level->currentPage()])->render() !!} @endif
或者
@if($three_level) {{ $three_level->appends(['oid'=>$oid,'sid'=>$sid,'three_level_page' => $three_level->currentPage()])->links() }} @endif
</div>
</div>
</div>