Pedro
Pedro

Reputation: 1477

Pagination and a Where clause

I there, im using eloquent to create a query where gets the galleries from a specific user_id, but i want also to implement the pagination, but is not working the way im doing.

ex:

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

Upvotes: 2

Views: 6441

Answers (2)

Aditya Singh
Aditya Singh

Reputation: 724

In the controller you are supposed to do :

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

In the view use :

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

Upvotes: 1

aleksejjj
aleksejjj

Reputation: 1835

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

Upvotes: 3

Related Questions