title: update pivot table in case of many to many relation laravel4
body: <p>I have started working with Laravel4 recently. I am facing some problem while updating pivot table data, in case of many to many relation.</p>
  
  <p>The situation is:
  I have two table: <strong>Product</strong>, <strong>ProductType</strong>. 
  The relation between them is <strong>Many to many</strong>. 
  My Models are </p>
  
  <pre><code>class Product extends Eloquent {
      protected $table = 'products';
      protected $primaryKey = 'prd_id';
  
      public function tags() {
          return $this-&gt;belongsToMany('Tag', 'prd_tags', 'prta_prd_id', 'prta_tag_id');
      }
  }
  
  class Tag extends Eloquent {
      protected $table = 'tags';
      protected $primaryKey = 'tag_id';
          public function products()
      {
      return $this-&gt;belongsToMany('Product', 'prd_tags', 'prta_prd_id', 'prta_tag_id');
      }
  }
  </code></pre>
  
  <p>While inserting data to the pivot table prd_tags, I did: </p>
  
  <pre><code>$product-&gt;tags()-&gt;attach($tag-&gt;tagID);
  </code></pre>
  
  <p>But now I want to update data in this pivot table, what is the best way to update data to the pivot table.
  Let's say, I want to delete some tags and add new tags to a particular product.</p>