title: Using the has() method a Laravel BelongsTo relation
body: <p>I have an Activity model and a Level model. Each Activity has one Level, so I have the following on Activity:</p>
  
  
  
  <pre class="lang-php prettyprint-override"><code>function level()
  {
     return $this-&gt;belongsTo('Level');
  }
  </code></pre>
  
  <p>And this on Level:</p>
  
  <pre class="lang-php prettyprint-override"><code>function activities()
  {
     return $this-&gt;hasMany('Activity');
  }
  </code></pre>
  
  <p>I then need to search for Activities that have a particular Level, so I am doing this:</p>
  
  <pre class="lang-php prettyprint-override"><code>$searchData = 'beginner';
  
  $query = $query-&gt;has(array('level' =&gt; function($query) use ($searchData)
  {
      $query-&gt;where('name', 'LIKE', '%' . $searchData . '%');
  }));
  </code></pre>
  
  <p>Using this throws a LogicException:</p>
  
  <pre class="lang-none prettyprint-override"><code>Has method invalid on "belongsTo" relations.
  </code></pre>
  
  <p>So I've either got the relationship wrong or I need to build the query in a different way.</p>
  
  <p>Any suggestions?</p>