From 4ee3d10da863a75d6bf5e2b14be8c72c7bf960df Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 15 Jun 2019 23:30:36 -0600 Subject: [PATCH] Update UserObserver --- app/Observers/UserObserver.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/Observers/UserObserver.php b/app/Observers/UserObserver.php index 542f0e317..db4b32b43 100644 --- a/app/Observers/UserObserver.php +++ b/app/Observers/UserObserver.php @@ -20,7 +20,7 @@ class UserObserver public function saved(User $user) { if (empty($user->profile)) { - DB::transaction(function() use($user) { + $profile = DB::transaction(function() use($user) { $profile = new Profile(); $profile->user_id = $user->id; $profile->username = $user->username; @@ -38,9 +38,16 @@ class UserObserver $profile->private_key = $pki_private; $profile->public_key = $pki_public; $profile->save(); + return $profile; + }); + DB::transaction(function() use($user, $profile) { + $user = User::findOrFail($user->id); + $user->profile_id = $profile->id; + $user->save(); CreateAvatar::dispatch($profile); }); + } if (empty($user->settings)) {