Skip to content

[13.x] Fix JSON:API resource collections wrapping plain objects - #62299

Merged
taylorotwell merged 1 commit into
laravel:13.xfrom
lazerg:fix/issue-62296-json-api-collection-non-model
Nov 3, 2026
Merged

taylorotwell merged 1 commit into
laravel:13.xfrom
lazerg:fix/issue-62296-json-api-collection-non-model

Conversation

@lazerg

@lazerg lazerg commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Since 13.39.0, a JSON:API resource collection whose resources wrap a plain object (not a model or an array) throws Cannot use object of type stdClass as array on every request.

#62152 collects the wrapped models with pluck('resource'), which goes through data_get(). A JsonResource is ArrayAccess, so data_get() calls offsetExists('resource') on it, and that does isset($this->resource['resource']) on the wrapped object. This reads the resource property directly instead.

Fixes #62296

@lazerg

lazerg commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

The CommandSignatureTest failure is already on 13.x from #62286 and is fixed by #62295, it is not from this change.

@taylorotwell
taylorotwell merged commit 1571da1 into laravel:13.x Nov 3, 2026
32 of 64 checks passed
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.

JSON:API resource collections fail for resources that wrap a non-model object

2 participants