From b03123300416b18158359871ba4ca88b3e9dc9b9 Mon Sep 17 00:00:00 2001 From: suraj kashyap Date: Tue, 18 Jun 2024 16:23:03 +0530 Subject: [PATCH] Minor changes. --- .../src/Repositories/AttributeRepository.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/Webkul/Attribute/src/Repositories/AttributeRepository.php b/packages/Webkul/Attribute/src/Repositories/AttributeRepository.php index f9eab295c..ed9c7eaab 100755 --- a/packages/Webkul/Attribute/src/Repositories/AttributeRepository.php +++ b/packages/Webkul/Attribute/src/Repositories/AttributeRepository.php @@ -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); } }