Replies: 4 comments
-
If this can be added without too much complexity, I might accept a PR. |
Beta Was this translation helpful? Give feedback.
-
Hi, old stuff... but has this ever been implemented? I don't seem to find in the docs and not able to implement it. |
Beta Was this translation helpful? Give feedback.
-
I've gotten it to work by using attribute casting. My issue is that I'm trying to also get it to work with Nova. Here's my custom accessor/mutator: public function options(): Attribute
{
return new Attribute(function ($value) {
while (is_string($value)) {
$value = json_decode($value, true);
}
return $value;
}, function ($value) {
return json_decode($value);
});
} It basically requires manually decoding the value. |
Beta Was this translation helpful? Give feedback.
-
I'm in the same boat, I've got a json field and it casts to an array and while it works and I can access the content of the field depending on language, if I use $model->locales() then it returns the language keys and the nested keys. At the moment I just have another array with supported language codes and I'm intersecting it with the field to get just the language keys but ideally it wouldn't return the nested keys available locales. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there,
do you have any plan to support nested fields in json for translatable fields ?
For example I have a field in my database stored as json and representing an array of objects. I wish I could add a simple field.*.label to the translatable attribute of my model instead of simply using a base field.
Thanks in advance for the answer. Since I really need this feature, any hint as to how to implement it would be most welcome, and if the solution we reach seems reliable enough maybe we'll open a PR to share our work.
Beta Was this translation helpful? Give feedback.
All reactions