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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -