2
votes

I have a Laravel aplication, with standard Authentication implemented. I would like to get the paginated list of the users in a table, but I get this error:

BadMethodCallException in Macroable.php line 81: Method paginate does not exist.

Here is the code:

$users = User::all()->paginate(25);

If I use this without calling the paginate() method, everything works well. Am I doing something wrong? I searched a lot, but I cannot find the answer.

1

1 Answers

3
votes

Try this code:

$users = User::paginate(25);

The thing is paginate() is kind of doing get() for you. And all() does it too.