Not work save to db from model, that was created from this type on select from db.
$newModel = Product::findOne($model->id);
$newModel->price; // is new Money(['value' => 10, 'currency_code' => 'USD'])
$newModel->price->value = 20;
$model->save(); - not work. In db still value = 10.
But your exemple with new model works fine:
$newModel = Product::findOne($model->id);
$model->price = new Money([
'value' => 10,
'currency_code' => 'USD'
]);
$model->save();
Not work save to db from model, that was created from this type on select from db.
$newModel = Product::findOne($model->id);
$newModel->price; // is new Money(['value' => 10, 'currency_code' => 'USD'])
$newModel->price->value = 20;
$model->save(); - not work. In db still value = 10.
But your exemple with new model works fine:
$newModel = Product::findOne($model->id);
$model->price = new Money([
'value' => 10,
'currency_code' => 'USD'
]);
$model->save();