Skip to content

Sync method not removing ids in belongsToMany relationship #72

Closed
@kmmathis

Description

@kmmathis

I have User and Role models, with each one having a belongsToMany relationship with the other, i.e. User belongsToMany Role and Role belongsToMany User.

Consider the following example:

$user = User::find("5294f9d695463439088b4569");
$user->roles()->sync(array("52953c599546345b048b456a", "52953c599546345b048b456b"));
// the above code puts the Role id's on the User document, as expected.
// it also puts the User id on the Role documents, as expected.

// later on...

$user->roles()->sync(array());
// that line removes the Role ids from the User document
// but it does not remove the User id from the Role documents

Shouldn't the User id be removed from the Role documents when the sync method passes an empty array? Or is that not what sync is meant to do?

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