Tambahkan kolom role di tabel pengguna

Mengubah query di UsersController untuk mengambil data roles. Memperbarui tampilan di users/index.blade.php untuk menampilkan kolom role dengan informasi yang sesuai.
This commit is contained in:
Daeng Deni Mardaeni
2024-11-17 11:43:19 +07:00
parent f362bdd32f
commit a2bff61998
2 changed files with 11 additions and 1 deletions

View File

@@ -105,7 +105,7 @@
$filteredRecords = $query->count();
// Get the data for the current page
$users = $query->with('branch')->get();
$users = $query->with(['branch','roles'])->get();
// Calculate the page count
$pageCount = ceil($totalRecords / $request->get('size'));

View File

@@ -72,6 +72,10 @@
<span class="sort"> <span class="sort-label"> Branch </span>
<span class="sort-icon"> </span> </span>
</th>
<th class="min-w-[185px]" data-datatable-column="role">
<span class="sort"> <span class="sort-label"> Role </span>
<span class="sort-icon"> </span> </span>
</th>
<th class="min-w-[50px] text-center" data-datatable-column="actions">Action</th>
</tr>
</thead>
@@ -162,6 +166,12 @@
return data.branch.name;
},
},
role: {
title: 'Role',
render: (item, data) => {
return data.roles.map(role => role.name).join(', ');
},
},
actions: {
title: 'Status',
render: (item, data) => {