title: Laravel eloquent whereIn with one query
body: <p>In laravel, I can use many where rules as an array a run one query to the database using laravel eloquent <code>where</code> method to get needed result.</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>$where = [];
  $where[] = ['user_id', '!=', null];
  $where[] = ['updated_at', '&gt;=', date('Y-m-d H:i:s')];
  if($request-&gt;searchTerm) {
      $where[] = ['title', 'like', '%' . $request-&gt;searchTerm . '%'];
  }
  Model::where($where)-&gt;get();
  </code></pre>
  
  <p><strong>Question part:</strong></p>
  
  <p>Now I need to use Laravel Eloquent method <code>whereIn</code> with array params to get needed result with one query.</p>
  
  <p>I tried by <strong>looping</strong> method but with many queries to the database.</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>$model = new Model;
  $whereIn = []; 
  
  $whereIn[] = ['date', '&gt;=', Carbon::now()-&gt;subDays(10)];
  $whereIn[] = ['user_role', 'candidate'];
  
  if (!empty($scope) &amp;&amp; is_array($scope)) {
      $whereIn[] = ['user_id', $scope];
  }
  if(is_array($employment) &amp;&amp; !empty($employment)) {
      $whereIn[] = ['employment', $employment];
  }
  if(is_array($experience) &amp;&amp; !empty($experience)) {
      $whereIn[] = ['experience', $experience];
  }
  
  foreach ($whereIn as $v) {
      $model = $model-&gt;whereIn($v[0], $v[1]);
  }
  
  dump($model-&gt;get());
  </code></pre>
  
  <p>First I tired <code>$model-&gt;whereIn($whereIn)-&gt;get()</code> but it's return error. It's possible get results with one query using <code>whereIn</code> without looping?</p>
  
  <p><strong>Note:</strong> My <code>$whereIn</code> array will be dynamic array!</p>