Start troubleshooting by using toSql().
To be honest i've never seen anything quite like that with paginate twice.
I use double pagination sometimes but each paginator has its own name.
Hello everyone, I hope all are doing good.
Here is my problem, How can I add pagination in laravel hasmany relationship?
Hashtag::withCount(['posts as count' => function($query) {
$query->active()
->whereHas('user', function ($subQuery) {
$subQuery->active();
});
}
])
->with([
'posts' => function ($query) {
$query->active()
->withWhereHas('user', function ($subQuery) {
$subQuery->active();
})
->withCount([
'likes as total_likes',
'comments as total_comments'
])
->orderByRaw('total_likes + total_comments DESC')
->paginate(5);
}
}]
->latest('count')
->paginate(10);
When I use paginate() or take(), limit() in with() then it will return incorrect records but when I remove paginate(), take() or limit() it will give all the posts of a hashtags.
Please or to participate in this conversation.