title: Laravel Eloquent query build select min value
body: <p>I am having the following query (trimmed) to list the rooms to user for booking:</p>
  
  <pre><code>$buildquery=Room::
  
          with(['hotel' =&gt; function ($query) {
              $query-&gt;where('status', 0);
          }])
  
          -&gt;with('image')-&gt;with('amenities');
  
          if ($request-&gt;filled('location_id')) {
              $buildquery-&gt;Where('city', $request-&gt;location_id);
          }
  
          $buildquery-&gt;Where('astatus', 1)-&gt;Where('status', 0);
  
          $rooms = $buildquery-&gt;simplePaginate(20);
  </code></pre>
  
  <p>Actual query (not trimmed):</p>
  
  <pre><code>select `rooms`.*, 
  (select count(*) from `amenities` inner join `amenities_room` on `amenities`.`id` = `amenities_room`.`amenities_id` where `rooms`.`id` = `amenities_room`.`room_id` and `amenities_id` in (?)) as `amenities_count` 
  from 
  `rooms` 
  where `city` = ? and `price` between ? and ? and `astatus` = ? and `status` = ? having 
  `amenities_count` = ? 
  limit 21 offset 100
  </code></pre>
  
  <p>It lists all the rooms available in hotel. I need to select only one room for one hotel with least price.</p>