title: Laravel 4: Eager loading
body: <p>I have a table called <code>UserWords</code> that has a <code>word_id</code> column in it, and I want to use that to get the row from the Words table, and kind of concatenate them together like a join. This way each one will have the info from the row in <code>UserWords</code> and <code>Words</code>. I defined the relation like so in <code>UserWord</code>:</p>
  
  <pre><code>class UserWord extends Eloquent{
      public function word(){
          $this-&gt;belongsTo('Word');
      }
  
  }
  </code></pre>
  
  <p>and then after that, I try to get all the UserWords and Words like so:</p>
  
  <pre><code>$words = UserWord::with("word")-&gt;
                  whereRaw("user_id = ".Auth::user()-&gt;id.
                  " AND lang1 = '".$lang1.
                  "' AND lang2 = '".$lang2."'")
                  -&gt;get();
  </code></pre>
  
  <p>This works if I don't have the with() in there. So, what am I doing wrong? Or am I going to have to create a raw <code>JOIN</code> to get what I want? I've never done relations before, so maybe I'm thinking of this fundamentally wrong? Either way, please teach me more than just giving the answer if you can! I read the docs and I think it should work, but it doesn't so... I'm asking here.</p>
  
  <p>EDIT: 
  The error I get is:</p>
  
  <pre><code>Call to a member function addEagerConstraints() on a non-object 
  </code></pre>