laravel 带条件的分页查询
1 <?php 2 3 class IndexController extends Controller 4 { 5 public function index(Request $request){ 6 $course_id = $request->input("course_id"); 7 $list = CourseInfo::where('course_id',$course_id)->orderBy("sort","desc"); 8 $list = $list->paginate(ConstantUtil::PAGE_SHOW); 9 10 //分页处理 11 $page = isset($page)?$request['page']:1; 12 $list = $list->appends(array( 13 'course_id'=>$course_id, 14 'page'=>$page 15 )); 16 return view('Admin/index/index',['list' => $list,'course_id'=>$course_id]); 17 } 18 } 19 20 ?>
HTML页面
1 <div class="dw-page"> {!! $list->links() !!} </div>