title: Call to function inside catch block returns undefined
body: <p>I'm using Laravel framework for an API that handles login and register features for a mobile app.
  The app has both Google authentication and my own custom login-register functionality.</p>
  <p>When a user <strong>uses google to register on the app</strong>, the next time they log in I want to <strong>check if their email already exists in the database</strong> by using validation in Laravel.</p>
  <p>Each time &quot;Sign in with Google&quot; button is clicked a request &quot;api/googleRegister&quot; with user information is sent and the function checks if the email is unique in database. If not the function googleLogin() is supposed to be executed but its returning undefined.</p>
  <pre><code>    function googleLogin(Request $request)
     {
      try {
         
        
              // Authentication passed...
              $user = auth()-&gt;user();
              $user-&gt;device_token = $request-&gt;input('device_token', '');
              $user-&gt;save();
              return $this-&gt;sendResponse($user, 'User retrieved successfully');
          
      } catch (\Exception $e) {
          return $this-&gt;sendError($e-&gt;getMessage(), 401);
      }
  
  }
  
  
      function googleRegister(Request $request)
   {
      try {
          $this-&gt;validate($request, [
              //'name' =&gt; 'required',
              'email' =&gt; 'required|unique:users|email',
              //'password' =&gt; '',
          ]);
          $user = new User;
          $user-&gt;name = $request-&gt;input('name');
          $user-&gt;email = $request-&gt;input('email');
          $user-&gt;device_token = $request-&gt;input('device_token', '');
          $user-&gt;password = Hash::make($request-&gt;input('password'));
          $user-&gt;api_token = str_random(60);
          $user-&gt;save();
  
          $defaultRoles = $this-&gt;roleRepository-&gt;findByField('default', '1');
          $defaultRoles = $defaultRoles-&gt;pluck('name')-&gt;toArray();
          $user-&gt;assignRole($defaultRoles);
  
      } catch (\Exception $e) {
          
          googleLogin($request);
         
      }
  
      return $this-&gt;sendResponse($user, 'User retrieved successfully');
  }
  </code></pre>