title: Laravel whereBetween in two columns
body: <p>i need to select products from DB by <code>whereBetween</code>.
  I have two <code>double</code> type columns in database, <code>price</code> and <code>newprice</code>.
  <code>Price</code> field is required and <code>newprice</code> is 0 by default. Admin writes <code>newprice</code> if there is any discounts on that product.</p>
  
  <p>Now my problem is it that i need to select from DB with <code>whereBetween</code> by <code>price</code> if <code>newprice == 0</code> and by <code>newprice</code> if <code>newprice != 0</code>.
  In a word filter by <code>newprice</code> if it is written, and by <code>price</code> if <code>newprice</code> is 0 by default.</p>
  
  <p>Here is my code. </p>
  
  <pre><code>$from = (int)$request-&gt;priceFrom;
  $to = (int)$request-&gt;priceTo;
  
  $products = Product::whereIn('category_id', $childCategories)-&gt;orWhere('category_id', $category-&gt;id)-&gt;where('publish', 1)-&gt;orderBy('created_at', 'desc');
  $products-&gt;whereBetween('price',array($from,$to))-&gt;orWhereBetween('newprice',array($from,$to));
  $products = $products-&gt;paginate(15);
  </code></pre>
  
  <p>It doesn't works correctly ofc. Any ideas? </p>