Reputation: 81
I'm trying to get this order by descend working, but for some reason an error keeps being thrown which is:
BadMethodCallException
inView.php
line 387: Method[orderBy]
does not exist on view.
I'm not sure why it can't find the orderBy
method.
public function display()
{
return view('users/timeline')
->with('user_name', 'body', 'location',
'photo', 'visibility', 'created_at')
->with('posts', Posts::all());
->orderBy('created_at', 'desc')
->get();
}
Upvotes: 2
Views: 5893
Reputation: 6264
Now you can use orderByDesc
directly:
Posts::orderByDesc('created_at')->get();
Upvotes: 2
Reputation: 163838
It should be:
Posts::orderBy('created_at', 'desc')->get();
Upvotes: 3