mhdmirzaie
7 months ago

How to orderBy and Paginate Posts with its Comments list

Posted 7 months ago by mhdmirzaie

Hi everyone,

I have written below eloquent command to fetch all posts with its comments. I want to orderBy it and also paginate it. It would be appreciated if help me.

$posts = Post::with('comments')->get(); return view('index')->with('posts', $reports);

Thanks,

Mohammad from Afghanistan

Please sign in or create an account to participate in this conversation.