Reputation: 33
I have two step registration on my website, and I'm trying to update user information data which I have in the data column. The first step is the username and last name and on second step I'm trying to insert additional data into my JSON column. This is my step two update:
$user->update([
'data' => [
'add_info' => json_encode($new_array_of_data)
]);
But this overwrites old data which I inserted on step one.
Upvotes: 0
Views: 1016
Reputation: 1503
To update json
type column, you need to use the following syntax:
$user->update(['data->add_info' => $your_data]);
According to: New JSON-column where() and update() syntax in Laravel 5.3
Upvotes: 1