[Issue] toArray() Data class method being called when returning a Paginated Collection but not with a single Data resource #175
Replies: 2 comments
-
Let me add a second indication that this may be a bug. When we have a CollectionOf Data objects, when you call the ->toArray() method on the collection Instance, the ->toArray() methods on each item are not called. |
Beta Was this translation helpful? Give feedback.
-
Please do not depend on overwriting Internally we try to use the transform method on a data object as much as possible because it has some extended information about the kind of transformation required. If you want to overwrite behavior, then please overwrite the |
Beta Was this translation helpful? Give feedback.
-
Hello!
@albert-mestres and I have been playing recently quite a lot with this package and we love it. We actually updated to the 2.0 version.
Now, we have two endpoints in which one is returning a PaginatedDataCollection and another which is returning directly a single Data object. For the paginated one, the toArray() method in the Data object is being called, while when we return directly the Data object from the controller, it is not being called.
We expected that the toArray() method was called always when a Data object is returned in a response. In any case, we think that could be an issue because of the different behaviours mentioned.
But on top of that, we also have this issue: #177
So to solve this current issue (#175), we had to call:
->toArray()
everywhere. But it turns out that, if we combine both->wrap('data')->toArray()
the ->wrap() method (solution of issue #177) is not working.Beta Was this translation helpful? Give feedback.
All reactions