2014-07-07 2 views
0

테이블 news이 있습니다. 내 컨트롤러에서laravel에서 페이징을 사용하는 방법

, 내가 쓰기 : 홈/현재보기에서

public function datnuoc(){ 

    $tinxkldMoi1 = DB::table ('news')->where ('datnuoc',1)->where('status',1)->orderBy('endDate', 'desc')->orderBy('created_at', 'desc')->paginate(20); 
    $tinxkldMoi2 = DB::table ('news')->where ('datnuoc',1)->take(5)->orderBy('endDate', 'desc')->orderBy('created_at', 'desc')->paginate(20); 
    $tinxkldMoi3 = DB::table ('news')->where ('datnuoc',1)->where('status',3)->take(5)->orderBy('endDate', 'desc')->orderBy('created_at', 'desc')->paginate(20); 

    return View::make ('home/current',array(
      'tinxkldMois1'=> $tinxkldMoi1, 
      'tinxkldMois2'=> $tinxkldMoi2, 
      'tinxkldMois3'=> $tinxkldMoi3, 

    )); 
} 

, 내가 쓴 :

<php> 
{{$tinxkldMois1->links()}} 
{{$tinxkldMois2->links()}} 
{{$tinxkldMois3->links()}} 
</php> 

나는 그것이 작동 한 부분을 클릭 할 때 온,하지만 어떻게 다른 사람들에게?

답변

0

동일한 쿼리에서 take()paginate()을 사용할 수 없으며 둘 다 limit을 설정하므로 take()이 무시됩니다. 마지막 두 쿼리의 경우 paginate(20)take(5)->get()

으로 바꿉니다.
관련 문제