title: join and group by not working properly in laravel
body: <p>I have a blog with 2 table. First <code>posts</code> table with a key <code>category_id</code> and <code>categories</code> table. In a page I want to show all categories with count of their posts. I write this query but it have a problem. It did not show categories with no posts. in other word categories with 0 posts did not appear in the results. </p>
  
  <p>And can you help to write this in eloquent system in laravel</p>
  
  <pre><code>SELECT categories.* , Count(posts.total) as total
  FROM categories
  LEFT JOIN 
  (
      SELECT * , COUNT(*) as total from posts GROUP By posts.id
  ) as posts
  ON posts.category_id = categories.id 
  </code></pre>