Open VicGUTT opened 1 month ago
@reinink Resolved any conflicts that arose after https://github.com/inertiajs/inertia-laravel/pull/641. This PR is now up to date with the 1.x
branch.
As a result, this PR only contributes the test_nested_arrayable_prop_response
test case in tests/ResponseTest.php
.
This test case is kept in place to ensure future changes does not break the evaluation of nested "Arrayable" instances as was previously the case with 620.
Prior to https://github.com/inertiajs/inertia-laravel/pull/620, property instances were resolved before handling arrayable/array values when sending a response.
Consider the following Inertia response dump:
AsArrayable
```php use Illuminate\Contracts\Support\Arrayable; class AsArrayable implements Arrayable { public function __construct(private array $data) {} public static function make(array $data): static { return new static($data); } public function toArray(): array { return $this->data; } } ```Before this fix, the dump would be similar to:
As we can see, nested (
user.organizations
) arrayable values are no longer resolved.After this fix, the dump is similar to:
This PR aims to bring back the behaviour prior to #620.