Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with modify data before updating hasOne model. #25

Open
AdrianKuriata opened this issue Apr 9, 2019 · 0 comments
Open

Problem with modify data before updating hasOne model. #25

AdrianKuriata opened this issue Apr 9, 2019 · 0 comments

Comments

@AdrianKuriata
Copy link

AdrianKuriata commented Apr 9, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant