groups
groups copied to clipboard
AddMembers issue
Hello @musonza I hope you are doing well. Is it normal that when I use the groups->addMembers method I get all the old members deleted from the group ? I want to add new members to the actual members This is the code I used
public function ajouterEleve(Request $request){
$eleves =$request->input('eleves');
$id=$request->input('groupId');
$group= Groups::group($id);
$group->addMembers($eleves);
return redirect()->back();
}
can you explain this please
public function addMembers($members)
{
if (is_array($members)) {
$this->users()->sync($members);
} else {
$this->users()->attach($members);
}
return $this;
}