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

User - Group relationship seems to be broken #125

Closed
LiquidPL opened this issue Oct 10, 2015 · 0 comments
Closed

User - Group relationship seems to be broken #125

LiquidPL opened this issue Oct 10, 2015 · 0 comments

Comments

@LiquidPL
Copy link
Contributor

Disclaimer: I am a total Laravel noob ATM, so anything I say might be wrong.

While looking through the code, i noticed in App\Models\User.php:

...

    public function groups()
    {

        return $this->hasMany("App\Models\Group");
    }

...

and in App\Models\Group.php:

...

    public function users()
    {
        return $this->hasMany("App\Models\User");
    }

...

These method names suggest that this was meant to be a many-to-many relationship.

However, in Laravel docs it is stated that you need to implement it like this:

    // App/Models/User.php

    public function groups()
    {
        return $this->belongsToMany("App\Models\User");
    }    

    // App/Models/Group.php

    public function users()
    {
        return $this->belongsToMany("App\Models\Group");
    }

Right now, I can't seem to add an user to a group using the ORM (i succeeded in doing so by editing the database manually), and I can't add more than one user to a group.

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