title: Laravel 5.3 distinct count, using eloquent instead of Query Builder
body: <p>Come across a weird issue, where i originally tried</p>
  
  <pre><code>$usersWithAnswersCount = GameResult::where([
      'school_id' =&gt; null,
      'season_id' =&gt; $this-&gt;season-&gt;id
  ])
  -&gt;groupBy('user_id')
  -&gt;count();
  </code></pre>
  
  <p>My table looks like</p>
  
  <p><a href="https://i.stack.imgur.com/4COvi.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4COvi.jpg" alt="enter image description here"></a></p>
  
  <p>However I was getting back the result <code>"1"</code> when it should have been returning back <code>"2"</code></p>
  
  <p>When I inspect what the query that ran was it was <code>select count(*) as aggregate from game_results where (school_id is null and season_id = '1') group by user_id</code> - which if i run directly as a mysql query returns back 2!!</p>
  
  <p>So it looks like something within eloquent is changing my 2 into a 1 :(</p>
  
  <p>However if i change this into the DB Query Builder and write out</p>
  
  <pre><code>$usersWithAnswersCount = DB::table('game_results')
  -&gt;selectRaw('count(distinct user_id) as count')
  -&gt;where([
      'school_id' =&gt; null,
      'season_id' =&gt; $this-&gt;season-&gt;id
  ])
  -&gt;first()-&gt;count;
  </code></pre>
  
  <p>I get back <code>"2"</code> which is what I expected.</p>
  
  <p>However I'm unclear why the Eloquent method fails, and what I can do to fix it if its possible.</p>