Skip to content

Commit 3dc117a

Browse files
committed
filter user list by company id
1 parent 5385353 commit 3dc117a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/backend/app/Http/Controllers/UserController.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ public function __construct(
1616
) {}
1717

1818
public function index(Request $request): ApiResource {
19-
$users = $this->userService->list();
19+
$companyId = auth()->user()->company_id;
20+
$users = $this->userService->list($companyId);
2021

2122
return new ApiResource($users);
2223
}

src/backend/app/Services/UserService.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,11 @@ public function resetPassword(string $email): ?User {
7171
return $user;
7272
}
7373

74-
public function list(): LengthAwarePaginator {
74+
public function list(int $companyId): LengthAwarePaginator {
7575
return $this->buildQuery()
7676
->select('id', 'name', 'email')
7777
->with(['addressDetails'])
78+
->where('company_id', $companyId) // filter user list with company_id
7879
->paginate();
7980
}
8081

0 commit comments

Comments
 (0)