Penambahan Akses Laman Dosen dab perbaikan fix

This commit is contained in:
Ariyutta
2026-11-09 12:01:30 +07:00
parent 33bc1233f7
commit ef46b84da8
48 changed files with 3018 additions and 131 deletions
+10 -3
View File
@@ -27,6 +27,9 @@ class Account extends User
public $timestamps = false;
/** Role yang boleh dipakai akun ini (pemilih peran); yang pertama = role bawaan. @var list<Role> */
public array $availableRoles = [];
/** t_jenisbagian: 1 Fakultas, 2 Jurusan, 3 Program Studi. */
private const int JENIS_BAGIAN_FAKULTAS = 1;
@@ -72,7 +75,7 @@ class Account extends User
* Isi atribut yang diharapkan aplikasi (name, username, role, is_active, profil).
* Mengembalikan null bila akun tidak bisa dipetakan ke role mana pun.
*/
public function hydrateLegacy(): ?static
public function hydrateLegacy(?Role $preferred = null): ?static
{
$jenis = (int) $this->jenis;
@@ -84,12 +87,16 @@ class Account extends User
->pluck('t.otoritas', 'o.idotoritas')
: collect();
$role = LegacyRole::resolve($jenis, $otoritas->keys()->map(fn ($id): int => (int) $id)->all(), $this->dosen_id !== null);
$available = LegacyRole::all($jenis, $otoritas->keys()->map(fn ($id): int => (int) $id)->all(), $this->dosen_id !== null);
if ($role === null) {
if ($available === []) {
return null;
}
// Role aktif = pilihan pengguna (dari pemilih peran) bila masih dimiliki akun, selain itu role bawaan.
$role = $preferred !== null && in_array($preferred, $available, true) ? $preferred : $available[0];
$this->availableRoles = $available;
$isPegawai = $jenis === LegacyRole::JENIS_PEGAWAI;
$nip = $this->nipnasional ?: $this->nip;