Explorar o código

Update AuthLogin listener

Daniel Supernault %!s(int64=4) %!d(string=hai) anos
pai
achega
8e8e6cafec
Modificáronse 1 ficheiros con 7 adicións e 0 borrados
  1. 7 0
      app/Listeners/AuthLogin.php

+ 7 - 0
app/Listeners/AuthLogin.php

@@ -42,6 +42,13 @@ class AuthLogin
     protected function userProfile($user)
     {
         if (empty($user->profile)) {
+            if($user->created_at->lt(now()->subDays(1))) {
+                $p = Profile::withTrashed()->whereUserId($user->id)->first();
+                if($p) {
+                    $p->restore();
+                    return;
+                }
+            }
             DB::transaction(function() use($user) {
                 $profile = Profile::firstOrCreate(['user_id' => $user->id]);
                 if($profile->wasRecentlyCreated == true) {