Laravel eloquent does not update JSON column : Array to string conversion
This code did the work for me.
$user = User::where('id', $request->user_id)
->first();
$array_data = ["json_key3"=>"value"];
$user->forceFill([
'db_column->json_key1->json_key2' => $array_data
])->save();
You can access your json keys using the arrow so you can update your column like so:
Flight::where('id', $id)->update([
'destinations->from' => $data['from'],
'destinations->to' => $data['to']
]);
As @fubar mentioned you have to have mysql 5.7 in order to have my solution to work.
check the docs
According to this conversation on Github : Make json attributes fillable if Model field is fillable Taylor Otwell recommande the use of save
method :
$model->options = ['foo' => 'bar'];
$model->save();
So in you case you can do it like this :
$flight = Flight::find($id);
$flight->destinations = $data;
$flight->save();