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

Fix toArray when using accessors on translatable attributes #437

Merged
merged 1 commit into from
Mar 1, 2024
Merged

Fix toArray when using accessors on translatable attributes #437

merged 1 commit into from
Mar 1, 2024

Conversation

vencelkatai
Copy link
Contributor

@vencelkatai vencelkatai commented Feb 29, 2024

Hi,

When using accessors on translatable attributes, the toArray method doesn't work like expected.
Normally when you get the value of an attribute, the accessor gets the translated value as its parameter. When using toArray on the model the accessor gets the raw value instead.
I've added a test to reproduce the issue.

This change only affects translated attributes with accessors, the mutateAttributeForArray method gets called only for attributes with accessors defined.

@freekmurze
Copy link
Member

It seems like the tests are failing, could you take a look?

@veencel
Copy link

veencel commented Feb 29, 2024

It should be fixed now. The expectation I was using was added lately, it failed on older pest versions.

@freekmurze freekmurze merged commit 529b4e8 into spatie:main Mar 1, 2024
19 checks passed
@freekmurze
Copy link
Member

Thanks!

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.

3 participants