Answer the question
In order to leave comments, you need to log in
How to make pagination for posts that belongsTo(User::class)?
I know that in order to paginate all articles, you need to write
$paginator = Post::simplePaginate($perPage);
A how it is done with the posts of a specific user that I want to display.
Here's what my code looks like without pagination:
$author_id = $request->input('author_id');
if ($author_id !== null) {
$author = User::find($author_id);
return view('blog.posts.index', compact('author'));
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question