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->belongsToMany('Bookmaker', 'bookmaker_user', 'user_id', 'bookmaker_id')
->withPivot('id', 'accountname')->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')->where('name', $bookname)->first();
$bookmaker = $this->user->bookmakers()->where('bookmaker_user.id','=',$id)->first();
$bookmaker->pivot->bookmaker_id = $bookmodif->id;
$bookmaker->pivot->save();
}
$id is the id of the account
$this->user is the user authentified.
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'.