Laravel页面多个列表 多个分页

  1. 控制器 ->paginate($this->paginate, [’*’], ‘自定义名称’);
  2. 页面
    {!! $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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值