lonnieezell / Bonfire2

CodeIgniter 4-based application skeleton

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Filtered users list displays multiple records for the same user if user is in multiple selected groups

dgvirtual opened this issue · comments

If the user is in a few groups and those groups are selected in the filter, the user is displayed multiple times:

paveikslas

I have traced this issue to the join method in UserFilter class, filter method that includes the join statement:

        if (isset($params['role']) && count($params['role'])) {
            $this->join('auth_groups_users agu', 'agu.user_id = users.id')
                ->whereIn('agu.group', $params['role']);
        }

the join statement makes the filter return one record for each group the user is assigned to, and joined to the main record is only the one group.

I am not sure there is a way to make the filter work properly at the model level (to work properly, the filter has to be applied after the model has retrieved the user list with all related groups). Therefore I cannot offer a simple solution.

Seems to be resolved.