Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AddMembers issue #25

Open
mehdielaissi opened this issue Sep 2, 2020 · 0 comments
Open

AddMembers issue #25

mehdielaissi opened this issue Sep 2, 2020 · 0 comments

Comments

@mehdielaissi
Copy link

mehdielaissi commented Sep 2, 2020

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;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant