DirectoryTree / LdapRecord

A fully-featured LDAP framework.
https://ldaprecord.com
MIT License
500 stars 44 forks source link

detach user group #683

Closed Arkantium closed 7 months ago

Arkantium commented 7 months ago

Environment: ActiveDirectory LdapRecord 3.1.2

Describe the bug: Hi,

In your documentation, you write:

if ($user->groups()->detach($group)) {
    // Successfully removed the group from the user.
}

But it's not possible to use an if statement on the deletion of a user's group because this method is an void and does not have return

 public function detach(mixed $model): void
    {
        if (is_iterable($model)) {
            array_map($this->detach(...), [...$model]);

            return;
        }

        $this->attemptFailableOperation(
            $this->buildDetachCallback($model),
            $this->bypass['detach'],
            $model
        );
    }

https://ldaprecord.com/docs/core/v3/active-directory/users/#removing-groups

stevebauman commented 7 months ago

Thanks! I've just patched this 👍

https://github.com/DirectoryTree/LdapRecord-Docs/commit/036f56a2eb05768669c48c2d5e66ebcaa81026a1