Problem with modify data before updating hasOne model.
AdrianKuriata opened this issue · 0 comments
Hello, I have a problem with package, i don't know, maybe I'm doing something wrong.
I have bootable trait bootConvertable with HasOneUpdating with anonymous function and two parameters, $parent and $model like in your documentation. When I dumping $model, everything is ok, working, but after change some values in model, this is not saved to the database (with laravel creating/updating etc. is ok). Example:
Method in trait which is used in User model:
protected static function bootConvertable()
{
static::hasOneUpdating(function ($parent, $model) {
$model->account_to_pay = '21122121221212121212121221';
});
}
Parent is User model with relation HasOne to UserProfile model. account_to_pay (is column in UserProfile) is not changed/saved to the database.
Could someone help with that? I don't know if problem is with other relations, I'm trying this relation for now.