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

[9.x] Support objects like GMP for custom Model casts #43959

Merged
merged 6 commits into from
Sep 1, 2022

Conversation

driesvints
Copy link
Member

@driesvints driesvints commented Sep 1, 2022

This PR fixes an issue where some objects like GMP objects couldn't be used as custom casts. The reason is that these objects cannot be converted to booleans so an if ($attribute[$key]) check will hard-fail. By using isset we can just check if the attribute is present and has a value.

Fixes #43870

@driesvints driesvints changed the title Use isset to support object like GMP Use isset to support objects like GMP Sep 1, 2022
@driesvints driesvints changed the title Use isset to support objects like GMP [9.x] Support objects like GMP for Eloquent Model casts Sep 1, 2022
@driesvints driesvints changed the title [9.x] Support objects like GMP for Eloquent Model casts [9.x] Support objects like GMP for custom Model casts Sep 1, 2022
@driesvints driesvints marked this pull request as ready for review September 1, 2022 09:27
@driesvints driesvints marked this pull request as draft September 1, 2022 09:35
@driesvints driesvints marked this pull request as ready for review September 1, 2022 09:44
@taylorotwell taylorotwell merged commit 4431fb3 into 9.x Sep 1, 2022
@taylorotwell taylorotwell deleted the fix-attribute-checking branch September 1, 2022 13:35
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.

Unable to cast database attributes to objects using custom casts
4 participants