Skip to content

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

Merged
taylorotwell merged 6 commits into
9.xfrom
fix-attribute-checking
Sep 1, 2022
Merged

taylorotwell merged 6 commits into
9.xfrom
fix-attribute-checking

Conversation

@driesvints

@driesvints driesvints commented Sep 1, 2022 •

Copy link
Copy Markdown
Member

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

3 participants