title: Eloquent has() in Many-To-Many
body: <p>I'm having a simple blog system, with a <code>posts</code>, <code>tags</code> and <code>posts_tags</code> table. The <code>posts</code> and <code>tags</code> table both have an <code>id</code> and a <code>content</code> field, whereas the <code>posts_tags</code> table has the fields <code>post_id</code> and <code>tag_id</code>. My eloquent models are:</p>
  
  <pre><code>class Post extends \Illuminate\Database\Eloquent\Model
  {
      public function tags()
      {
          return $this-&gt;belongsToMany('Tag', 'posts_tags', 'post_id', 'tag_id');
      }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>class Tag extends \Illuminate\Database\Eloquent\Model
  {
      public function posts()
      {
          return $this-&gt;belongsToMany('Post', 'posts_tags', 'tag_id', 'post_id');
      }
  }
  </code></pre>
  
  <p>Now, as far as I understood, if I call <code>Post::has('tags')-&gt;get()</code> I should get the posts which have at least one tag (which all do). But all I get is an empty array (which I get when calling <code>Tag::has('posts')-&gt;get()</code>, too). What am I doing wrong?</p>