title: Laravel eloquent - how to use DB raw inside custom relationship
body: <p>I have laravel models :
  Post and Comment. As normal, post will have many comment 
  tables as bellow: </p>
  
  <pre><code>Posts table
  --------------------------------------
  |id   |title   |                     |
  --------------------------------------
  |1    |test    |
  
  comments table: 
  --------------------------------------
  |id   |post_id |   created_at       |
  --------------------------------------
  |1    |1          |2015-09-12 09:01:02 |    
  --------------------------------------
  |2    |1          |2015-09-12 09:03:02 |
  </code></pre>
  
  <p>now I want to query for the post with the most number of comments from current date back to last 7 days. 
  Here is my code in Laravel Controller: </p>
  
  <pre><code>$posts= Post::whereHas(
           'comments', function ($q) {
               $q-&gt;select(DB::raw("DATE_FORMAT(created_at,'%Y-%m-%d %H:%i:%s')"),'post_id',DB::raw('count(*) as cmt_count'))
               -&gt;where(DB::raw('`comments`.`created_at` BETWEEN NOW()-INTERVAL 8 DAY AND NOW()'))
                   -&gt;groupBy('post_id');
  
           })
           -&gt;take(5)-&gt;get();
  </code></pre>
  
  <p>got the ERROR: </p>
  
  <pre><code>QueryException in Connection.php line 651: SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 3 column(s) (SQL: select * from `posts` where (select DATE_FORMAT(created_at,'%Y-%m-%d %H:%i:%s'), `post_id`, count(*) as cmt_count from `comments` where `comments`.`post_id` = `posts`.`id` and `comments`.`created_at` BETWEEN NOW()-INTERVAL 8 DAY AND NOW() is null group by `post_id`) &gt;= 1 limit 5)
  </code></pre>
  
  <p>Please help to point me what am I doing wrong ? </p>