title: SELECT list is not in GROUP BY clause and contains nonaggregated column 'explore.ratings.id'
body: <p>What I'm trying to do is selecting the trips , then group them by rate.</p>
  
  <blockquote>
    <p>note: ratings is a polymorphic relationship</p>
  </blockquote>
  
  <p>given we have 2 models :</p>
  
  <pre><code>trips
    id =&gt; int
    price =&gt; float
    city_id =&gt; uint
  ........
  
  ratings:
    id =&gt; int
    ratable_id =&gt; int
    ratable_type=&gt; varchar
    rate =&gt; small-int
  ......
  </code></pre>
  
  <p>and here how am trying to do it:</p>
  
  <pre><code>\App\Models\Trip::where('price','&gt;=','100')-&gt;with(['ratings' =&gt; function ($query) {
          $query-&gt;groupBy('ratings.rate');
      }])-&gt;get();
  </code></pre>
  
  <p>and <code>Whoops!</code>:</p>
  
  <blockquote>
    <p>"SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1
    of SELECT list is not in GROUP BY clause and contains nonaggregated
    column 'explore.ratings.id' which is not functionally dependent on
    columns in GROUP BY clause; this is incompatible with
    sql_mode=only_full_group_by (SQL: select * from <code>ratings</code> where
    <code>ratings</code>.<code>ratable_id</code> in (1, 2) and <code>ratings</code>.<code>ratable_type</code> =
    App\Models\Trip group by <code>ratings</code>.<code>rate</code>)</p>
  </blockquote>