title: How to get nested count via Eloquent?
body: <p>I have simple nested tree model:</p>
  
  <p><strong>Page table</strong></p>
  
  <pre><code>id
  owner_id
  title
  </code></pre>
  
  <p>Any page can have similar Pages related by key <code>owner_id</code> and refers to the same table records.</p>
  
  <p>How to get some page with count of the nested pages by <code>id</code> through Eloquent?</p>
  
  <p>In a native SQL i can do something like this:</p>
  
  <pre><code>SELECT pages.*, count(subPage.id) AS childCount
  FROM pages AS page
  LEFT JOIN pages AS subPage ON (subPage .owner_id = page.id)
  ....
  </code></pre>
  
  <p>Something like this:</p>
  
  <p><code>$page-&gt;childsCount</code> will return count of related sub pages.</p>