I want to update a JSON column in my database but I get this error :
Array to string conversion
I have declared the column name as array in the model :
protected $casts = [
'destinations' => 'array'
];
this is the code that I use :
$data[] = [
'from' => $fromArray,
'to' => $toArray
];
Flight::where('id', $id)->update(['destinations' => $data]);
What should I do ?
$flight = Flight::find($id); $flight->destinations = $data; $flight->save();see heresetDestinationsAttribute()mutator which was the real culprit.