[Superuser] Perbaikan Halaman Akses Superuser
This commit is contained in:
@@ -35,6 +35,14 @@ final class CalendarEvents
|
||||
{
|
||||
$rows = $this->db()->table('t_unituser')->where('iduser', $iduser)->get(['idfak', 'idprogdi']);
|
||||
$ids = $rows->pluck('idfak')->merge($rows->pluck('idprogdi'))->filter()->map(fn ($id): int => (int) $id)->unique()->values();
|
||||
|
||||
// Akun otoritas pusat tanpa unit (mis. Administrator Pusat): semua fakultas lalu semua prodi.
|
||||
if ($ids->isEmpty()) {
|
||||
$scope = app(UnitScope::class);
|
||||
if ($scope->isUnlimited($iduser)) {
|
||||
$ids = collect($scope->allFaculties())->merge($scope->allPrograms()->keys())->values();
|
||||
}
|
||||
}
|
||||
$names = $this->db()->table('t_bagian')->whereIn('idbagian', $ids->all())->pluck('namabagian', 'idbagian');
|
||||
|
||||
return $ids->mapWithKeys(fn (int $id): array => [$id => trim((string) ($names[$id] ?? '')) ?: 'Unit '.$id])->all();
|
||||
|
||||
Reference in New Issue
Block a user