title: Laravel 5 Eloquent relationship: can't modify/overwrite relationship table property
body: <p>I am using Laravel 5's <code>belongsToMany</code> method to define related tables using an intermediary pivot table. My application is using the eloquent models <strong>Tour</strong> and <strong>TourCategory</strong>. In the Tour Model I have:</p>
  
  <pre><code>namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  
  class Tour extends Model
  {
      public function cats(){
          return $this-&gt;belongsToMany('App\TourCategory', 'tour_cat_assignments', 'tour_id', 'cat_id');
      }
  
  }
  </code></pre>
  
  <p>In my controller I am retrieving all the data from the tour table along with the associated category data using Laravel's <code>with</code> method:</p>
  
  <pre><code>$tours = Tour::with('cats')-&gt;get();
  </code></pre>
  
  <p>That all works fine. The problem is that I don't want the category data in its current raw form, I need to first rearrange it. However I cannot overwrite the <code>cats</code> property without unsetting it first:</p>
  
  <pre><code>public function serveTourData(){
  
      $tours = Tour::with('sections', 'cats')-&gt;get();
  
      foreach($tours as $tour){
  
          unset($tour-&gt;cats); // If I unset first, then it respects the new value. Why do I need to do this?
  
          $tour-&gt;cats = "SOME NEW VALUE";
      }
  
      Log::info($tours);
  }
  </code></pre>
  
  <p>Can someone explain the logic behind this please?</p>