title: How to pass array as SELECT params for Laravel Query Builder
body: <p>If I have an AJAX call that returns an array called <code>$selectArray</code>, which is <code>[foo,bar,foobar]</code>, how do utilize it in a Laravel Query Builder so that it's sanitized? Currently, I have</p>
  
  <pre class="lang-php prettyprint-override"><code>// Sanitizing Input
  // $acceptableSelects is an array of columns in a table. Checks if there are any elements in $selectArray that is invalid
  // If the check fails, it return the default array
  $sanSelectArray = !array_diff($selectArray, array_keys($accetableSelects)) &amp;&amp; count($selectArray) &lt; 8 ? $selectArray : [foo,foo2,foo3]
  
  foreach($sanSelectArray as $ele){
      $query-&gt;addSelect('table.' . $ele); // Required since I have a LEFT JOIN
  }
  </code></pre>
  
  <p>It seems awfully unintuitive. Either there are better ways sanitizing the input or passing Array as <code>SELECT</code> without having multiple <code>addSelect()</code> methods, but I can't find any. </p>