title: Laravel 4 Eloquent many-to-many condition parameter
body: <p>For a Laravel application I'm working on, I would like to do something like this with my Eloquent models:</p>
  
  <pre><code>$product = Product::with('terms')-&gt;find(1);
  
  $brand = $product-&gt;terms('brand');
  $color = $product-&gt;terms('color');
  </code></pre>
  
  <p>The terms is a many to many relationship. Terms in this context, is terms of taxonomies. So a products terms could be: Nike, Red, Boys, etc.
  And if I do <code>$product-&gt;terms</code> I get all terms, and when I do <code>$product-&gt;terms('brand')</code> I get 'Nike' for instance.</p>
  
  <p>Right now my Product model is like this:</p>
  
  <pre><code>class Product extends Eloquent {
      protected $guarded = array();
  
      public static $rules = array();
  
      public function terms($taxonomy)
      {
          return $this-&gt;belongsToMany('Term', 'productterms');
      }
  
  }
  </code></pre>
  
  <p>Is it even possible to do what I'm trying to achieve?</p>