Skip to content

Commit

Permalink
added group permission on users datagrid
Browse files Browse the repository at this point in the history
  • Loading branch information
prabhat-webkul committed Mar 28, 2024
1 parent 319d500 commit df18819
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/Webkul/Admin/src/DataGrids/Setting/UserDataGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit df18819

Please sign in to comment.