title: Laravel query builder - How to either group by alias, or do raw groupBy
body: <p>My Laravel 5 app includes a dynamic query builder for report running. I need some group by clauses in there and have run into a problem. If I use actual sql in there I can have issues as sometimes there needs to be a sql command in amongst the sql (as opposed to straightforward column names), ie - <code>DAYNAME(table_name.date_column)</code>. Laravel mangles this: </p>
  
  <pre><code>\`DAYNAME(table_name\`.\`date_column)\`
  </code></pre>
  
  <p>For the select part of my query I can use selectRaw, but there does not seem to be an equivaent for group by.</p>
  
  <p>I thought of using aliases (all the selects are aliased) but Laravel wraps them in "`" characters as well. Besides - my app needs to work with both MySQL and SQL Server and as far as I know the latter does not allow aliases in the group by section of the query. </p>
  
  <p>I can find the method in Illuminate\Database\Query\Grammars\Grammar where the group by is compiled (compileGroups) and I suppose I could override it but I'm not too sure how I would go about that (have read the Laravel docs).</p>