Update a Belongs to Relationship in Laravel

If you have a model that belongs to another model, for example, account belongs to user. This would be defined in the account in the following way.

    public function user() {
        return $this->belongsTo(User::class);
    }

If you want to transfer the account to a different user, you could do the following:

$account->user()->associate($newUser);
$account->save();

In the database, this has the effect of changing the value of the user_id foreign key found in the account record.