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();
}
It should be:
Posts::orderBy('created_at', 'desc')->get();