title: Laravel agroup data by idParent
body: <p>I use laravel to make a api and now I need help to agroup records in my table companies.</p>
  <p>I use this code to make get data:</p>
  <pre><code>Company::orderBy('created_at')
           -&gt;get();
  </code></pre>
  <p>And this result this data:</p>
  <pre><code>id | idParent | companyName
  1  | null     | Company A
  2  | 1        | Company B
  3  | null     | Company C
  4  | 3        | Company D
  5  | 1        | Company E
  6  | 3        | Company F
  </code></pre>
  <p>How can I get the data agroup by idParent like this:</p>
  <pre><code>id | idParent | companyName
  1  | null     | Company A
  2  | 1        | Company B
  5  | 1        | Company E
  3  | null     | Company C
  4  | 3        | Company D
  6  | 3        | Company F
  </code></pre>
  <p>Any help will be welcome.</p>
  <p>Thanks!!</p>