title: Laravel get class name of related model
body: <p>In my Laravel application I have an <code>Faq</code> model.  An <code>Faq</code> model can contain many <code>Product</code> models, so the <code>Faq</code> class contains the following function:</p>
  
  <pre><code>class Faq extends Eloquent{ 
      public function products(){
          return $this-&gt;belongsToMany('Product');
      }
  }
  </code></pre>
  
  <p>In a controller, I would like to be able to retrieve the class name that defines the relationship.  For example, if I have an <code>Faq</code> object, like this:</p>
  
  <pre><code>$faq = new Faq();
  </code></pre>
  
  <p>How can I determine the class name of the relationship, which in this case would be <code>Product</code>.  Currently I am able to do it like this:</p>
  
  <pre><code>$className = get_class($faq-&gt;products()-&gt;get()-&gt;first());
  </code></pre>
  
  <p>However, I'm wondering if there is a way to accomplish this same thing without having to actually run a query.</p>