title: Laravel Eloquent join table and count related
body: <p>I have two tables, categories and product. I'm trying to add a query to count products of each category without foreach of the categories. I reached the query below:</p>
  
  <pre><code>DB::table('categories')-&gt;leftJoin('product', 'categories.id', '=','categpry_id')
  -&gt;selectRaw('categories.*, count(product.id) as Count')
  -&gt;where('product.status',1)
  -&gt;groupBy('categories.id')
  -&gt;get();
  </code></pre>
  
  <p>But the problem I'm facing is when a category doesn't have products it's not showing. I want to show the categories with no product with 0 product in the array.</p>