title: Laravel : Search by min and max value from the table
body: <p>I am confuse about search with <code>min-max</code> value.In my <code>posts</code> table there is a two field <code>min_price</code> and <code>max_price</code>, on my search there is a couple of thing which I need to covered in search query.</p>
  
  <ol>
  <li><p>If user search with only <code>max_value</code>, it shows all the posts which price is <code>less than or equal to max_value</code>.</p></li>
  <li><p>If user search with only <code>min_value</code>, it shows all the posts which price is <code>less than or equal to min_value</code>.</p></li>
  <li><p>If user search with <code>min_value</code> and <code>max_value</code>, it shows all the posts which price is between <code>min_value and max_value</code>.</p></li>
  <li><p>If both null, return all posts.</p></li>
  </ol>
  
  <p>How can I do this ?</p>
  
  <p>My code:</p>
  
  <pre><code>$searchablePost = Post::with(['product','postattribute.attribute.category','user.userDetails'])
                   -&gt;whereIn('product_id', $userApprovalProductIDs)
                  -&gt;whereIn('demand_or_supply', $demand_or_supply);
  
  // skip my search query code
  
  $searchedPost = $searchablePost-&gt;offset($offset)-&gt;limit($limit)-&gt;orderBy('id','desc')-&gt;get();
  </code></pre>
  
  <p>How can I do t</p>