dynamitem
dynamitem

Reputation: 1669

Laravel 4 pagination

My pagination doesn't seem to work. Here's how I done it:

$players = Auth::user()->players->paginate(2);

And then done all the stuff that's needed in the view, but:

Call to undefined method Illuminate\Database\Eloquent\Collection::paginate()

It shows the line, where that variable is.

Upvotes: 0

Views: 361

Answers (2)

Abishek
Abishek

Reputation: 11691

Try

Auth::user()->players()->paginate(2);

Auth::user()->players returns a collection, the paginate function belongs to the Builder class of Eloquent.

Upvotes: 2

dynamitem
dynamitem

Reputation: 1669

Nevermind, solved it myself:

Solution:

Auth::user()->players()->paginate(2);

Upvotes: 0

Related Questions