We are trying to use JSON datatypes to store Profile
dynamic data, and do not know all of the hard-coded field names to add to the fillable
property in model. how to set (insert
if the key not exists | update
if the key exists) just one key, not all of them?
For example if we want to update just age
and we use:
$model = Profile::find($profile_id);
$model->options = json_encode(['age' => '21']);
$model->save();
this solution isn't a great option, because it overrides everything else. How can we set just the desired fields without changing other fields (JSON keys)?