php - Laravel eloquent does not update JSON column : Array to string conversion -
i want update json column in database error :
array string conversion
i have declared column name array
in model :
protected $casts = [ 'destinations' => 'array' ];
this code use :
$data[] = [ 'from' => $fromarray, 'to' => $toarray ]; flight::where('id', $id)->update(['destinations' => $data]);
what should ?
according conversation on github : make json attributes fillable if model field fillable taylor otwell recommande use of save
method :
$model->options = ['foo' => 'bar'];
$model->save();
so in case can :
$flight = flight::find($id); $flight->destinations = $data; $flight->save();
Comments
Post a Comment