$posts = Post::all()->orderby('created_at','desc')->where('usr_id','=',session('LoggedUser'))->get();
return view('admin.profile',compact('userInfo' , 'posts'));
i am making a custom auth for a journal activity but i cant sort the content i shows this error
"Method Illuminate\Database\Eloquent\Collection::orderby does not exist. "
I believe this might be because you typed
orderbyinstead oforderBy(notice the uppercase). See laravel orderBy documentation if needed.Plus, as mentionned by other, don't use
all()if you need to do other thing (where clause, order by, etc) in you query.