Reputation: 1
$article = Article::all()->sortBy("order")->paginate(3);
return view('nieuws' , compact('article'));
wont work this is the error I get back: Method Illuminate\Database\Eloquent\Collection::paginate does not exist.
Upvotes: 0
Views: 243
Reputation: 34668
When you're using all()
you get all the rows from the table and get a collection. You can only invoke "paginate"
on a Query, not on a Collection. :
$article = Article::orderBy("order")->paginate(3);
There is no sortBy()
method on the query builder, it should be orderBy
. You can only invoke "sortBy"
on a Collection, not on a Query.
Upvotes: 2