2016-10-21 11 views
1

私は、特定のuser_idからギャラリーを取得するクエリーを作成するために雄弁を使用していますが、私もページネーションを実装したいと思います。ページネーションとWhere句

例:ビューの使用では

$galleries = Gallery::where('user_id', $userId)->paginate(10); 

:あなたが行うことになっているコントローラで

$galleries = Gallery::paginate(10)->where('user_id', $userId) 
      ->get(); 
+0

$ギャラリー=ギャラリー:: ( 'user_id'、$ userId) - >ページネート(10); –

答えて

2
$galleries = Gallery::where('user_id', $userId)->paginate(10); 
1

{{ $galleries->appends(Input::except('page'))->links() }}