Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.x] Call toArray() on Arrayable props resolved from the Container #696

Open
wants to merge 1 commit into
base: 2.x
Choose a base branch
from

Conversation

pascalbaljet
Copy link

There's a bug in v2.0 in which Arrayable instances that are resolved from the container, for example with deferred props, are not correctly resolved because toArray() is never called on them. This PR fixes that and adds a test for it.

In the scenario below, both Users and Departments implement the Arrayable interface, but when resolving departments on a partial request, it currently returns an empty object.

return inertia('Users', [
    'users' => Users::make(),
    'departments' => Inertia::defer(fn () => Departments::make()),
]);

@pascalbaljet pascalbaljet changed the title Call toArray() on Arrayable props resolved from the Container [2.x] Call toArray() on Arrayable props resolved from the Container Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant