Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Many to many, can't get related objects #75

Copy link
Copy link
Closed
@rcwsr

Description

@rcwsr
Issue body actions

I'm implementing a many to many relationship between two models, User and Club. The documentation says "The belongsToMany relation will not use a pivot "table", but will push id's to a related_ids attribute instead.".

However, I've set up belongsToMany on both models, and when attaching or syncing, a pivot table is created named, for example. user_club. I can even specify the name of the pivot-table in my models, as well as pass extra attributes to store in the pivot-table when syncing or or attaching. When creating the relationship, nothing is stored Is this expected behavior?

If it is, then I'm having trouble getting related items. For example, I'm trying to display all the users that belong to a club with $users = $club->users();. But in a var_dump, I can't see anything related to users. Am I doing something wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.