title: Laravel 5.2.29 Many to Many relationship not working
body: <p>I am trying to implement many to many relationship using a pivot table. The name of my pivot table is "post_tag" and column names are "post_id" and "tag_id". The post and tag model classes look like below.</p>
  
  <pre><code>class Post extends Model
  {
      protected $fillable = array(
          'title',
          'text',
          'active',
          'user_id'
      );
  
      public function user()
      {
          return $this-&gt;belongsTo('App\Post');
      }
  
      public function comments()
      {
          return $this-&gt;hasMany('App\Comment');
      }
  
      public function tags()
      {
          return $this-&gt;hasMany('App\Post', 'post_id');
      }
  
  }
  </code></pre>
  
  <p>And the tag class is as below:</p>
  
  <pre><code>class Tag extends Model
  {
      public function posts()
      {
          return $this-&gt;hasMany('App\Post');
      }
  }
  </code></pre>
  
  <p>The post_tag table looks like below:</p>
  
  <pre>
  post_id tag_id
  1        1  
  1        2  
  2        1  
  </pre>
  
  <p>I am trying the tags for the post using the following code:</p>
  
  <pre><code>$user = User::find(1);
      foreach ($user-&gt;posts as $post) {
          foreach ($post-&gt;tags as $tag) {
              print $tag-&gt;title;
              print "&lt;br&gt;";
          }
          print "&lt;br&gt;";
      }
  </code></pre>
  
  <p>But it throws an error:</p>
  
  <p>QueryException in Connection.php line 729:
  SQLSTATE[42S22]: Column not found: 1054 Unknown column 'posts.post_id' in 'where clause' (SQL: select * from <code>posts</code> where <code>posts</code>.<code>post_id</code> = 1 and <code>posts</code>.<code>post_id</code> is not null)</p>
  
  <p>I think I missing something. Could anyone please let me know.</p>
  
  <p>Thanks</p>