feat(ui): Perbaikan tampilan dan fungsionalitas halaman index untuk manajemen pengguna

- Memperbaiki fungsi export data pengguna dengan format yang lebih rapi
- Update semua controller (Permissions, Positions, Roles, Users) untuk konsistensi response dan error handling
- Tambahan fungsi `goPage(1)` pada event listener pencarian untuk langsung ke halaman pertama saat melakukan pencarian
This commit is contained in:
Daeng Deni Mardaeni
2025-08-20 09:41:52 +07:00
parent c348af2484
commit 59721337a8
7 changed files with 143 additions and 120 deletions

View File

@@ -79,10 +79,16 @@
// Retrieve data from the database
$query = User::query();
if(!$this->user->hasRole('administrator')){
$query->whereHas('roles', function($q){
$q->where('name', '!=', 'administrator');
});
}
// Apply search filter if provided
if ($request->has('search') && !empty($request->get('search'))) {
$search = $request->get('search');
$query->whereAny(['name','email'],'like','%'.$search.'%');
$query->whereAny(['name', 'email'], 'like', '%'.$search.'%');
}
// Apply sorting if provided
@@ -108,7 +114,7 @@
$filteredRecords = $query->count();
// Get the data for the current page
$users = $query->with(['branch', 'roles'])->get();
$data = $query->with(['branch', 'roles'])->get();
// Calculate the page count
$pageCount = ceil($totalRecords / $request->get('size'));
@@ -124,7 +130,7 @@
'pageCount' => $pageCount,
'page' => $currentPage,
'totalCount' => $totalRecords,
'data' => $users,
'data' => $data,
]);
}
@@ -144,6 +150,9 @@
$user = User::find($id);
$roles = Role::all();
if(!$this->user->hasRole('administrator')){
$roles = $roles->where('name', '!=', 'administrator');
}
$branches = Branch::all();
return view('usermanagement::users.create', compact('user', 'roles', 'branches'));
}
@@ -234,6 +243,9 @@
}
$roles = Role::all();
if(!$this->user->hasRole('administrator')){
$roles = $roles->where('name', '!=', 'administrator');
}
$branches = Branch::all();
return view('usermanagement::users.create', compact('roles', 'branches'));
}