diff --git a/packages/Webkul/Admin/src/DataGrids/Setting/UserDataGrid.php b/packages/Webkul/Admin/src/DataGrids/Setting/UserDataGrid.php index 2713dffbd..271968eeb 100644 --- a/packages/Webkul/Admin/src/DataGrids/Setting/UserDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/Setting/UserDataGrid.php @@ -28,6 +28,22 @@ public function prepareQueryBuilder() 'users.created_at' ); + $loggedUser = auth() + ->guard('user') + ->user(); + + $permission = $loggedUser->view_permission; + + if ($permission == 'group') { + $queryBuilder + ->rightJoin( + 'user_groups', + 'users.id', '=', 'user_groups.user_id' + ); + } elseif ($permission == 'individual') { + $queryBuilder->where('users.id', $loggedUser->id); + } + $this->addFilter('id', 'users.id'); $this->setQueryBuilder($queryBuilder);