$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. "
Change the orderby to orderBy. This could be the reason you are getting the error.
Or...
If you want to get specific number of posts you can do it this way to avoid using the
Post::all