Updating translatable fields to null or empty is not working as expected #356
Replies: 2 comments
-
Unless you include a key/value pair specifying which language the Remember that the mutation will work for each field independently. So, it will work the same as $model->update([
'name' => ['en' => 'Name en', 'hr' => 'Name hr'],
]);
$model->update([
'description' => null,
]); The A different case would have been using the Collection For example: $collection = Model::get() // <= This is a "collection", not a "model instance"
$collection->update([
'description' => null,
]) That's because the |
Beta Was this translation helpful? Give feedback.
-
I also stumbled on this problem today after client reported that current translations aren't getting removed when values for each locale is empty on update.
|
Beta Was this translation helpful? Give feedback.
-
Example for create:
In DB I get data saved as JSON (as expected).
Example for update:
In DB I am getting
{"en":null}
instead of null. Why isn't saved as null (it is nullable column in DB), but asen: null
?Beta Was this translation helpful? Give feedback.
All reactions