Update UserObserver

This commit is contained in:
Daniel Supernault 2019-06-15 23:30:36 -06:00
parent e3c11f76ae
commit 4ee3d10da8
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -20,7 +20,7 @@ class UserObserver
public function saved(User $user) public function saved(User $user)
{ {
if (empty($user->profile)) { if (empty($user->profile)) {
DB::transaction(function() use($user) { $profile = DB::transaction(function() use($user) {
$profile = new Profile(); $profile = new Profile();
$profile->user_id = $user->id; $profile->user_id = $user->id;
$profile->username = $user->username; $profile->username = $user->username;
@ -38,9 +38,16 @@ class UserObserver
$profile->private_key = $pki_private; $profile->private_key = $pki_private;
$profile->public_key = $pki_public; $profile->public_key = $pki_public;
$profile->save(); $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); CreateAvatar::dispatch($profile);
}); });
} }
if (empty($user->settings)) { if (empty($user->settings)) {