Laravel 4.2 Eager Loading 4 tables
<p>I've got a problem I've not faced before with Eager Loading in Laravel.</p>

<p>I have the following table structure</p>

<pre><code>- Letter
    id,
    sentence_id

- Sentence
    id,
    paragraph_id

- Paragraph
    id,
    book_id

- Book
    id
</code></pre>

<p><strong>belongsTo/belongsToMany:</strong></p>

<ul>
<li><code>letter-&gt;belongsToMany('Sentence')</code></li>
<li><code>sentence-&gt;belongsTo('Paragraph')</code></li>
<li><code>paragraph-&gt;belongsTo('Book')</code></li>
</ul>

<p><strong>has/hasMany:</strong></p>

<ul>
<li><code>book-&gt;hasMany('Paragraph')</code></li>
<li><code>paragraph-&gt;hasMany('Sentence')</code></li>
<li><code>sentence-&gt;hasMany('Letter')</code></li>
</ul>

<p>This all works great. However, if I want to get all the letters in the book, I have can't seem to figure out the correct way to do this.</p>

<p>I've tried <code>hasManyThrough</code> but quickly realized that does not serve the purpose I'm trying to achieve.</p>

<p>I then thought I could use <code>Eager Loading</code> WITH <code>hasManyThrough</code> something to the effect of.</p>

<pre><code>public function sentences(){
    return $this-&gt;hasManyThrough('Sentence', 'Paragraph');
}
</code></pre>

<p>Which I could then do something like:</p>

<pre><code>Book::sentences()-&gt;with(['letters' =&gt; function($q) use (&amp;$letters){
    $letters = $q-&gt;get()-&gt;unique();
}]);
</code></pre>

<p>However this does not seem to establish the relationship correctly.</p>

<p>What is the best way to access <code>D</code> through <code>A</code>?</p>