I am building an API which needs below post data with many eager loaded relation. Here is how I have tried, its working but I can't limit the number of replies, adding ->limit(1) is not giving any effect.
How I can optimize query is so slow (taking 5 sec in local machine) since its returning huge data.
Limit the result from eager loaded relation
I am building an API which needs below
post
data with many eager loaded relation. Here is how I have tried, its working but I can't limit the number ofreplies
, adding ->limit(1) is not giving any effect.How I can optimize query is so slow (taking 5 sec in local machine) since its returning huge data.
Is there any other way to do this, I am using laravel
LengthAwarePaginator
and I don't know how to add custom data inpaginate
collection.One way will be to first get the post then
loop over
and load all therealations
needed. but I will lose the pagination. Please help