title: How to chain DB relationships in Laravel (multiple has_many?)
body: <p>I'm using Laravel, which is awesome, but I'm stuck on an issue with the database.</p>
  
  <p>Let's say we have three tables, like so:</p>
  
  <p><strong>TABLE 1: pages</strong></p>
  
  <pre><code>id    |   route   |  title
  </code></pre>
  
  <p><strong>TABLE 2: elements</strong></p>
  
  <pre><code>id    |   page_id   |  type
  </code></pre>
  
  <p><strong>TABLE 3: content</strong></p>
  
  <pre><code>id    |   element_id   |  data
  </code></pre>
  
  <p>I'd like to do a single selection for the page that will in turn select all of the elements with that page id, and for each of the elements it should select all of the content rows with the element id. </p>
  
  <p>I want to have a static <strong>load_by_route($route)</strong> function in the Page model that, when called, will use the route to load and return the page info as well as the elements and content as described above. Ideally it would return a single object/array with all of this info.</p>
  
  <p>Basically, I'm not sure how to chain the has_many() calls together so that I get the two-level relationship.</p>