无论是tp还是laravel,我发现在进行带有搜索分页的时候都是第一页好好的,但是第二页就存在问题了,可能还是和分页的获取方式有关吧,在百度的时候,基本上就没有找到什么东西,Google下,呵呵哒!我的是5.2版本的
按照普通分页那样
public function getEnrollMentor(Request $request){
$where = /你们要写入的条件/;
//例如我的
DB::table('enrolls_view')
->where(function($query) use ($age){
if(!empty($age)){
$age = explode(',',$age);
foreach($age as $key=> $year){
$stime= strtotime("$year years ago");
$startDate = date("Y-m-d",$stime );
$yearEnd = $year+10;
$etime = strtotime("$yearEnd years ago");
$endDate = date("Y-m-d",$etime);
$query->orWhereBetween('person_birthday',
array($endDate,$startDate));
}
}
})
->paginate(8);
}
$page = isset($page)?$request['page']:1;
$enrollmentor = $enrollmentor->appends(array(
'work'=>$request['work'],
'page'=>$page
//add more element if you have more search terms
));
view中
<td colspan="3" align="center" id="pageBar">{!! $enrollmentor->links() !!} </td>