Skip to content

Commit

Permalink
Minor changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
suraj-webkul committed Jun 18, 2024
1 parent d8c12b5 commit b031233
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,20 +137,17 @@ public function getLookUpOptions($lookup, $query = '', $columns = [])
$columns = [($lookup['value_column'] ?? 'id') . ' as id' , ($lookup['label_column'] ?? 'name') . ' as name'];
}

// Check user repo and restrict listing as per given permission
if (Str::contains($lookup['repository'], 'UserRepository')) {
$userRepository = app($lookup['repository']);

$loggedUser = auth()->guard('user')->user();
$currentUser = auth()->guard('user')->user();

$permission = $loggedUser->view_permission;

if ($permission === 'group') {
return $userRepository->rightJoin('user_groups', 'users.id', '=', 'user_groups.user_id')
if ($currentUser->view_permission === 'group') {
return $userRepository->leftJoin('user_groups', 'users.id', '=', 'user_groups.user_id')
->where('users.name', 'like', '%' . urldecode($query) . '%')
->get();
} elseif ($permission === 'individual') {
return $userRepository->findByField('users.id', $loggedUser->id);
} elseif ($currentUser->view_permission === 'individual') {
return $userRepository->findByField('users.id', $currentUser->id);
}
}

Expand Down

0 comments on commit b031233

Please sign in to comment.