title: How to get all records in if conditions using laravel
body: <p>I have two request parameters in array: </p>
  
  <pre><code>       {
  "users": [1,2,3],
  "groups": [1,2]
        }
  </code></pre>
  
  <p>I want to get records of users against id 1,2,4 and groups against id 1,2 i can fetch records of users but i am unable to fetch records of groups.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>                       public function isGroupUser(Request $request)
  {
      $usersDetail = $request-&gt;input('users', []);
      $groupsDetails = $request-&gt;input('groups', []);
  
      if($usersDetail)
      {
          $users = DB::table('users')
              -&gt;join('user_basic_info','users.id','=','user_basic_info.user_id')
              -&gt;select('users.id','user_basic_info.first_name')
              -&gt;whereIn('users.id',$usersDetail)-&gt;get();
          $resultArray = ['users' =&gt; $users];
  
          return \Illuminate\Support\Facades\Response::json($resultArray, 200);
      }
  
      elseif ($groupsDetails)
      {
          $groups = DB::table('group')
              -&gt;select('group.id','group.name')
              -&gt;whereIn('group.id',$groupsDetails)-&gt;get();
          $resultArray = ['groups' =&gt; $groups];
  
          return \Illuminate\Support\Facades\Response::json($resultArray, 200);
      }
  
  
  
  }
  </code></pre>
  
  <p>I can get the records of users but not getting groups
  where i am wrong?
  your help will be highly appreciated!</p>
  
  <p>Currently my json response:</p>
  
  <pre><code>               {
  "users": [
      {
          "id": 1,
          "first_name": "Admin"
      },
      {
          "id": 2,
          "first_name": "Admin"
      },
      {
          "id": 3,
          "first_name": "Admin"
      }
  ]
     }
  </code></pre>
  
  <p>But not getting the groups.
  Your help needs here.</p>