laravel 带条件的分页查询

laravel 带条件的分页查询,

原文:http://blog.csdn.net/u011020900/article/details/52369094

bug:断点查询,点击分页,查询条件消失。

思路:追加(appends)查询条件

 1  $taskList = TaskList::where('assignedTo','=',$assignedTo)
 2 ->where($ary_where)->where($ary_where1)
 3 ->where($ary_where2)->orderBy('status_order','asc')
 4 ->orderBy('finishedDate','desc')->paginate(3);
 5        
 6         //分页处理
 7         $page = isset($page)?$request['page']:1;
 8         $taskList = $taskList->appends(array(
 9             'title'=>$title,
10             'project'=>$project,
11             'status'=>$status,
12             'page'=>$page
13             //add more element if you have more search terms
14         ));

view页面

<div style="margin: 0px" >{!! $taskList->links() !!}</div>

  

 

posted @ 2017-10-20 09:56  万里冰封  阅读(3524)  评论(0编辑  收藏  举报