Model/User.php
public function setGroups(array $groups)
    {
        $this->groups = [];

        foreach ($groups as $item) {
            $this->addGroup($item);
        }

        return $this;
    }
public function setGroups(array $groups)
    {
        $this->groups = [];

        foreach ($groups as $item) {
            $this->addGroup($item);
        }

        return $this;
    }
Sets the "groups" of the User.

@param Group[] $groups

@return User