[Superuser] Integrasi Pertama ke Database
This commit is contained in:
@@ -94,6 +94,38 @@ orm (nilai isian ubah), lainnya tidak dapat diubah.
|
||||
->through(fn (object $row): array => $this->present($row, $types, $filter['units'] ?? null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Periode yang aktif di setidaknya satu program studi (terbaru) bila ada di daftar, kalau tidak periode terbaru.
|
||||
*
|
||||
* @param Collection<int, string> $periods
|
||||
*/
|
||||
public function currentPeriod(Collection $periods): ?int
|
||||
{
|
||||
$active = $this->db()->table('t_periodekuliahaktif')->max('idperiode');
|
||||
|
||||
return $active !== null && $periods->has((int) $active) ? (int) $active : $periods->keys()->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Semua kegiatan satu periode dengan tanggal mentah (Y-m-d), berurutan TMT; dipakai kalender bersama semua role.
|
||||
*
|
||||
* @return Collection<int, array{id: int, jenis: string, keterangan: string, mulai: string, selesai: string}>
|
||||
*/
|
||||
public function schedule(int $periode): Collection
|
||||
{
|
||||
return $this->base()
|
||||
->where('k.idperiodekuliah', $periode)
|
||||
->orderBy('k.mulai')->orderBy('k.idkegiatan')
|
||||
->get()
|
||||
->map(fn (object $row): array => [
|
||||
'id' => (int) $row->idkegiatan,
|
||||
'jenis' => trim($row->jeniskegiatan),
|
||||
'keterangan' => trim((string) $row->deskripsi),
|
||||
'mulai' => substr((string) $row->mulai, 0, 10),
|
||||
'selesai' => substr((string) $row->selesai, 0, 10),
|
||||
]);
|
||||
}
|
||||
|
||||
/** Jumlah baris jalur minimum per minggu agar tinggi minggu tetap lega walau kegiatannya sedikit. */
|
||||
private const int MIN_LANES = 3;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user