Answer the question
In order to leave comments, you need to log in
Why does ResourceCollection work differently?
I want to get a collection of posts using pagination
. I do: $user->posts()->paginate()
and everything outputs normally. All posts are in data, there are also links and so on.
I want to wrap it in a PostCollection.
If you do it like this, then everything works:
return new PostCollection(
$user->posts()->paginate()
);
return $this->setDataEndRender([
'posts' => new PostCollection(
$user->posts()->paginate()
)
]);
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