Reputation: 151
I am trying to paginate with an orderBy tag and I am having issues with it. Here is my code:
$posts = Post::where('draft', '=', 0)->orderBy('created_at', 'id')->paginate(1)->get();
return View::make('home')->with('posts', $posts);
But it returns with:
Missing argument 1 for Illuminate\Support\Collection::get()
Can someone help me with my errors. Thanks
Upvotes: 1
Views: 955
Reputation: 219938
Just drop the call to get()
. The paginate
method itself already does the database query:
$posts = Post::where('draft', '=', 0)->orderBy('created_at', 'id')->paginate(1);
return View::make('home')->with('posts', $posts);
Upvotes: 2