Replies: 2 comments
-
That's the difference between a Model and a Collection.
Use
or just
The |
Beta Was this translation helpful? Give feedback.
-
Thank you for that. The update method works fine that way, however the create method doesn't. This only occurs when the payload is a FormData object, otherwise it works fine with model objects too. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am working on a laravel/vue app with multi language models. Spatie/Translatable worked fine for me, until I used formData, because I needed to send an image. I had to use JSON.stringify() to convert my translate objects into JSON. In my Laravel function, when I use a Builder object to save data in database, everything works fine. for example:
this is my payload:
title: {"en":"English Title","fr":"French title"}
this works fine:
But this messes up the data saved in the name field:
This saves the json that should be saved in the field in the first language "en". And does not save anything to the second language "fr" as it did in the first example.
I tried to json_decode it before inserting it into the database, but doesn't work.
Beta Was this translation helpful? Give feedback.
All reactions