title: Using whereIn method to return multiple results for the same array value but at different index
body: <p>$pidArray contains product ID's, some of those product ID's can be the same. I.E: 34 34 56 77 99 34. As is, it appears the whereIn method does not return results for a productId it has already found in $pidArray, even if it has a different index.</p>
  
  <pre><code> $productDataForOrder = Product::whereIn('id', $pidArray)-&gt;get(['id','price']);
  
  
   $totalAmount = $productDataForOrder-&gt;sum('price');
  </code></pre>
  
  <p>$productDataForOrder now contains product data, but only for unique ProductID's in $pidarray. So when sum function is run, the sum is wrong as it does not take into account the price for multiple instances of the same productID.</p>
  
  <p>The following code also does not return objects for every product ID in the array which are the same. So if $pidArray contains three identical product ID's, the query will only return a collection with one object, instead of three.</p>
  
  <pre><code>   $query = Product::select();
          foreach ($pidArray as $id)
          {
              $query-&gt;orWhere('id', '=', $id);
          }
  
          $productDataForOrder = $query-&gt;get(['id','price']);
  
          $totalAmount = $productDataForOrder-&gt;sum('price');
  </code></pre>