-
-
Notifications
You must be signed in to change notification settings - Fork 213
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
Compatibility with spatie/laravel-translatable is broken #870
Comments
I think I've fixed it, but could be that the change breaks everything 😅, this Eloquent attributes thing a magic black box and every time it seems to be working differently. Solution would be not to initialize the properties in the beginning, then we'll try to call Commit: d017301 |
It did break stuff, I'm just testing this and now it's the opposite of this issue in another translation lib https://github.com/Astrotomic/laravel-translatable/blob/main/src/Translatable/Translatable.php#L143 It uses Seeing as in laravel getAttribute calls getAttributeValue I think it should go back to using |
@Tofandel You're referencing the Astronomic package, as far as I know it now works with the Spatie package. You're always welcome to send in a PR with solution which works for both. |
✏️ Describe the bug
Version 4.6.0 introduced a new
NormalizedModel
.In which, after some time, the method for obtaining model attributes was changed. And that broke the compatibility.
Because of this, translatable attributes began to come to the data class as arrays, instead of strings.
An we got this error
We can write workarounds to avoid problems.
But... It looks terrible
I can create a custom
ModelSerializer
, but then I'll have to completely repeatNormalizedModel
and make changes there.The simplest solution is to make the
$properties
property of theNormalizedModel
class public and then I can use my custom normalizer right afterModelNormalizer
and cast the translatable properties to a string. Also adding a setter as mentioned in #803 would also solve the problem...Please tell me, is this possible? Or maybe there is another way to solve the problem?
This problem was also mentioned in #851
Thank you for reading.
↪️ To Reproduce
Unfortunately there is no test to show the problem
🖥️ Versions
Laravel: 10.48.22
Laravel Data: 4.9.0
PHP: 8.3
The text was updated successfully, but these errors were encountered: