From c6b1164620ce72775f35eff265ed5d31386a67e7 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 24 Oct 2018 12:41:14 -0600 Subject: [PATCH] Update AuthLogin --- app/Http/Controllers/Auth/RegisterController.php | 2 +- app/Listeners/AuthLogin.php | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 2907de68..9a8ef07a 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -31,7 +31,7 @@ class RegisterController extends Controller * * @var string */ - protected $redirectTo = '/home'; + protected $redirectTo = '/'; /** * Create a new controller instance. diff --git a/app/Listeners/AuthLogin.php b/app/Listeners/AuthLogin.php index e8a274e0..f587c66a 100644 --- a/app/Listeners/AuthLogin.php +++ b/app/Listeners/AuthLogin.php @@ -2,6 +2,7 @@ namespace App\Listeners; +use DB; use App\User; use App\UserSetting; use Illuminate\Queue\InteractsWithQueue; @@ -29,9 +30,11 @@ class AuthLogin { $user = $event->user; if (empty($user->settings)) { - $settings = new UserSetting(); - $settings->user_id = $user->id; - $settings->save(); + DB::transaction(function() use($user) { + UserSetting::firstOrCreate([ + 'user_id' => $user->id + ]); + }); } } }