title: Laravel: How to determine the type of owners of a many to many polymorphic relation?
body: <p>I follow the <a href="https://laravel.com/docs/4.2/eloquent#many-to-many-polymorphic-relations" rel="nofollow">example here</a> and made a many to many polymorphic relation. I have:</p>
  
  <pre><code>tags:
  -PHP
  -movie
  </code></pre>
  
  <p>If I run this</p>
  
  <pre><code>Route::get('tag/{id}/', function($id){    
    $tag = Tag::find($id);
    return $tag;    
  });
  </code></pre>
  
  <p>The website will give me this</p>
  
  <pre><code>{"id":2,"name":"movie","created_at":null,"updated_at":null}
  </code></pre>
  
  <p>If I lucky or I know for sure that this tag belongs to a post, when I use</p>
  
  <pre><code>return $tag-&gt;posts; 
  </code></pre>
  
  <p>It will return me the array with info of the post. But how can I determine the type of owner (post or video) that the tag belongs to so I can use appropriate functions(like posts or videos)?
  In the one to many polymorphic relation example, I can look at imageable_type to know which type of owner(order, staff) I'm dealing with. But I can't retrieve taggable_type in many to many polymorphic. I tried</p>
  
  <pre><code>Route::get('tag/{id}/', function($id){    
      $tag = Tag::find($id);
      return $tag-&gt;taggable;
  });
  </code></pre>
  
  <p>but nothing happened. How can I retrieve this attribute? I'm using Laravel 5.2.39.</p>