belongsToMany(Character::class,'wowpress_charlists_item','character_id','list_id')->orderBy('character_id')->orderByPivot('date')->withPivot('comment','date','ID'); } public function addItem(Character $char, $comment = null, $date = null, $multiplier = 1){ $this->characters()->attach($char->ID,[ 'comment' => $comment, 'date' => $date?:date('Y-m-d'), 'count_multiplier' => $multiplier ]); if($this->notify){ if($char->user){ Notification::addNotification($char->user->ID,'Neuer Eintrag in Liste: '.$this->list_name); } } } public function removeItem($id){ $this->characters()->wherePivot('id',$id)->first()->detach(); } }