title: How to access model hasMany Relation with where condition?
body: <p>I created a model Game using a condition / constraint for a relation as follows:</p>
  
  
  
  <pre class="lang-php prettyprint-override"><code>class Game extends Eloquent {
      // many more stuff here
  
      // relation without any constraints ...works fine 
      public function videos() {
          return $this-&gt;hasMany('Video');
      }
  
      // results in a "problem", se examples below
      public function available_videos() {
          return $this-&gt;hasMany('Video')-&gt;where('available','=', 1);
      }
  }
  </code></pre>
  
  <p>When using it somehow like this:</p>
  
  <pre class="lang-php prettyprint-override"><code>$game = Game::with('available_videos')-&gt;find(1);
  $game-&gt;available_videos-&gt;count();
  </code></pre>
  
  <p>everything works fine, as roles is the resulting collection.</p>
  
  <p><strong>MY PROBLEM:</strong></p>
  
  <p>when I try to access it without eager loading</p>
  
  <pre class="lang-php prettyprint-override"><code>$game = Game::find(1);
  $game-&gt;available_videos-&gt;count();
  </code></pre>
  
  <p>an Exception is thrown as it says "<em>Call to a member function count() on a non-object</em>".</p>
  
  <p>Using</p>
  
  <pre class="lang-php prettyprint-override"><code>$game = Game::find(1);
  $game-&gt;load('available_videos');
  $game-&gt;available_videos-&gt;count();
  </code></pre>
  
  <p>works fine, but it seems quite complicated to me, as I do not need to load related models, if I do not use conditions within my relation.</p>
  
  <p>Have I missed something? How can I ensure, that available_videos are accessible without using eager loading?</p>
  
  <p>For anyone interested, I have also posted this issue on <a href="http://forums.laravel.io/viewtopic.php?id=10470">http://forums.laravel.io/viewtopic.php?id=10470</a></p>