title: laravel/eloquent mutators/accessors in a pivot table
body: <p>Well, I think the title explains most of it.  Lets get right into it!</p>
  
  <p>Blank Model:</p>
  
  <pre><code>class Blank extends Eloquent 
  {
  
      protected $table = 'blanks';
  
      protected $softDelete = true;
  
      protected $hidden = array();
  
      /**
       * Get associated jobs.
       *
       * @return mixed
       */
      public function jobs()
      {
          return $this-&gt;belongsToMany('Job')-&gt;withPivot('status', 'inventory', 'sizes', 'mill', 'po', 'location', 'ordered_at', 'expected_at', 'note')-&gt;withTimestamps();
      }
  
      /**
       * Blanks sizes accessor
       *
       * @return object
       */
      public function getSizesAttribute($value)
      {
          return json_decode($this-&gt;pivot-&gt;sizes);
      }
  
      /**
       * Blanks sizes mutator
       *
       * @return void
       */
      public function setSizesAttribute($value)
      {
          $this-&gt;pivot-&gt;attributes['sizes'] = json_encode($this-&gt;pivot-&gt;sizes);
      }
  
  }
  </code></pre>
  
  <p>Job Model:</p>
  
  <pre><code>class Job extends Eloquent
  {
  
      protected $table = 'jobs';
  
      protected $softDelete = true;
  
      protected $hidden = array();
  
      /**
       * Get associated blank.
       *
       * @return mixed
       */
      public function blanks()
      {
          return $this-&gt;belongsToMany('Blank')-&gt;withPivot('status', 'inventory', 'sizes', 'mill', 'po', 'location', 'ordered_at', 'expected_at', 'note')-&gt;withTimestamps();
      }
  
      /**
       * Blanks sizes accessor
       *
       * @return object
       */
      public function getSizesAttribute($value)
      {
          return json_decode($this-&gt;pivot-&gt;sizes);
      }
  
      /**
       * Blanks sizes mutator
       *
       * @return void
       */
      public function setSizesAttribute($value)
      {
          $this-&gt;pivot-&gt;attributes['sizes'] = json_encode($this-&gt;pivot-&gt;sizes);
      }
  }
  </code></pre>
  
  <p>Attaching Code: </p>
  
  <pre><code>$job-&gt;blanks()-&gt;attach($blank-&gt;id,[
      'status'      =&gt; Input::get('status'),
      'inventory'   =&gt; Input::get('inventory'),
      //'sizes'       =&gt; $sizes,
      'mill'        =&gt; Input::get('mill'),
      'po'          =&gt; Input::get('po'),
      'location'    =&gt; Input::get('location'),
      'ordered_at'  =&gt; Carbon::parse(Input::get('ordered_at'))-&gt;format('Y-m-d H:i:s'),
      'expected_at' =&gt; Carbon::parse(Input::get('expected_at'))-&gt;format('Y-m-d H:i:s'),
      'note'        =&gt; Input::get('note'),
  ]);
  </code></pre>
  
  <p>The mutator is not being called at all.. Any ideas?</p>