Blogger Information
Blog 9
fans 0
comment 0
visits 20571
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
TP5.1 分页(带参数传递)
霸霸的博客
Original
4726 people have browsed it

控制器代码

实例

$goodsList = Db::table('goods')
     ->whereIn('id',$goodsListId)
     ->paginate(1,false, ['query' => request()->param()]) //将请求中的参数全部传入
     ->each(function($item,$key){
          $item['imagepath'] = explode(',', $item['imagepath']);
          // 将这个$item的数据返回
          return $item;
       });

最主要就是paginate(1,false, ['query' => request()->param()]),第一个参数是每页显示的数量,第二个是简易模式,第三个参数是请求的参数,['query' => request()->param()]这样写可以直接把所有参数传入,也可以一个一个写['query' => ['id' => $id,'...' => '...']]将参数传入

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post