title: Updating pivot table by id in laravel
body: <pre><code>bookmaker table
  id
  name
  
  
  bookmaker_user table
  id 
  account_name
  bookmaker_id
  user_id
  
  
  user table
  id
  name
  
  User Model :
  public function bookmakers(){
      return $this-&gt;belongsToMany('Bookmaker', 'bookmaker_user', 'user_id', 'bookmaker_id')
              -&gt;withPivot('id', 'accountname')-&gt;withTimestamps();
  }
  
  
  BookmakerController.php
  public function update($id)
  {
              $bookname = Input::get('booknamemodifselect');
              $accountname = Input::get('accountnamemodifinput');
              $bankrollinvested = Input::get('bankrollinvestedmodifinput');
              $bonus = Input::get('bonusmodifinput');
              $bankrollamount = Input::get('bankrollamountmodifinput');
  
              $bookmodif = DB::table('bookmakers')-&gt;where('name', $bookname)-&gt;first();
  
  
              $bookmaker = $this-&gt;user-&gt;bookmakers()-&gt;where('bookmaker_user.id','=',$id)-&gt;first();
              $bookmaker-&gt;pivot-&gt;bookmaker_id = $bookmodif-&gt;id;
              $bookmaker-&gt;pivot-&gt;save();
      }
  </code></pre>
  
  <p>$id is the id of the account</p>
  
  <p>$this->user is the user authentified.</p>
  
  <p>I want to update the bookmaker for an account by his id (by account id I mean) that belongs to the user auth. Because the user auth have multiple entries with the same bookmaker but different account name.
  It says 'Trying to get property of non-object'.</p>