Scope users listing and search to current company (#607)

Add scopeWhereCompany() to User model using whereHas through the
user_company pivot table. Apply it in UsersController::index() and
SearchController so users only see members of their current company.

Previously, the users page showed ALL users across all companies.

Ref #574
This commit is contained in:
Darko Gjorgjijoski
2026-04-03 14:34:33 +02:00
committed by GitHub
parent 3d871604ae
commit 7d9fdb79cc
3 changed files with 12 additions and 3 deletions

View File

@@ -25,7 +25,8 @@ class SearchController extends Controller
->paginate(10);
if ($user->isOwner()) {
$users = User::applyFilters($request->only(['search']))
$users = User::whereCompany()
->applyFilters($request->only(['search']))
->latest()
->paginate(10);
}