You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In v2 Arrayable props are only converted to arrays if they are "regular" props. This happens because closures are resolved later than arrayable props: see here
IMHO this conversion should happen either on all forms of prop definition or never.
One solution would be to move resolveArrayableProperties after resolvePropertyInstances, this solves this issue but I did not test the effects on the whole system.
Backstory:
We use spatie media library in our project and passed the MediaCollection directly to the inertia view. After the v2 upgrade we noticed that ['propname' => $collection] and ['propname' => fn () => $collection] behaves differently.
This happens because
['propname' => $collection] calls toArray because of the Arrayable check but
['propname' => fn () => $collection] is not doing this so it will be fall back to toJson in the end which has a different implementation.
The text was updated successfully, but these errors were encountered:
In v2 Arrayable props are only converted to arrays if they are "regular" props. This happens because closures are resolved later than arrayable props: see here
IMHO this conversion should happen either on all forms of prop definition or never.
One solution would be to move
resolveArrayableProperties
afterresolvePropertyInstances
, this solves this issue but I did not test the effects on the whole system.Backstory:
We use spatie media library in our project and passed the MediaCollection directly to the inertia view. After the v2 upgrade we noticed that
['propname' => $collection]
and['propname' => fn () => $collection]
behaves differently.This happens because
['propname' => $collection]
callstoArray
because of the Arrayable check but['propname' => fn () => $collection]
is not doing this so it will be fall back totoJson
in the end which has a different implementation.The text was updated successfully, but these errors were encountered: