Commit awal: prototipe UI SIAKAD Untan

This commit is contained in:
Ariyutta
2026-10-24 11:45:32 +07:00
commit d9b9cb5c0f
477 changed files with 51958 additions and 0 deletions
@@ -0,0 +1,50 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Enums\Role;
use App\Http\Controllers\Controller;
use App\Support\Prototype\Sample;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
class DashboardController extends Controller
{
public function __invoke(Request $request): View
{
$role = Role::Admin;
$user = $request->user()->loadMissing($role->profileRelation());
$profile = $user->{$role->profileRelation()};
// Label => nilai; kolom kosong dilewati.
$details = array_map(strval(...), array_filter([
'Username' => $user->username,
$role->identifierLabel() => $profile?->nip,
'Jabatan' => $profile?->jabatan,
'Unit kerja' => $profile?->unit_kerja,
], fn (mixed $value): bool => $value !== null));
$fakultas = Sample::fakultas();
$perStatus = Sample::mahasiswa()->countBy('status');
$today = today()->toDateString();
return view('admin.dashboard', [
'user' => $user,
'details' => $details,
'stats' => [
'fakultas' => $fakultas->count(),
'prodi' => Sample::prodi()->count(),
'dosen' => Sample::dosen()->count(),
'mahasiswa' => (int) $fakultas->sum('mahasiswa'),
'mataKuliah' => Sample::mataKuliah()->count(),
],
'fakultasLabels' => $fakultas->pluck('kode')->all(),
'fakultasData' => $fakultas->pluck('mahasiswa')->all(),
'statusLabels' => $perStatus->keys()->all(),
'statusData' => $perStatus->values()->all(),
'tahun' => Sample::tahunAkademik()->firstWhere('aktif', true),
'pengumuman' => Sample::pengumuman()->where('status', 'Terbit')->sortByDesc('tanggal')->take(3)->values(),
'agenda' => Sample::kalender()->filter(fn (array $e): bool => ($e['selesai'] ?? $e['mulai']) >= $today)->sortBy('mulai')->take(4)->values(),
]);
}
}
@@ -0,0 +1,82 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Prototype\ResourceController;
use App\Support\Prototype\Sample;
use Illuminate\Support\Collection;
use Illuminate\Validation\Rule;
class DosenController extends ResourceController
{
private const STATUS = ['Aktif' => 'Aktif', 'Cuti' => 'Cuti', 'Tugas belajar' => 'Tugas belajar'];
private const JABATAN = ['Asisten Ahli' => 'Asisten Ahli', 'Lektor' => 'Lektor', 'Lektor Kepala' => 'Lektor Kepala', 'Guru Besar' => 'Guru Besar'];
protected function rows(): Collection
{
return Sample::dosen();
}
protected function routeBase(): string
{
return 'admin.dosen';
}
protected function names(): array
{
return ['singular' => 'Dosen', 'plural' => 'Dosen', 'description' => 'Data dosen, jabatan fungsional, status kepegawaian, dan jumlah mahasiswa bimbingan.'];
}
protected function keyName(): string
{
return 'nidn';
}
protected function search(): array
{
return ['nidn', 'nama', 'email'];
}
/** @return array<string, string> */
private function prodiOptions(): array
{
return Sample::prodi()->pluck('nama', 'nama')->all();
}
protected function filters(): array
{
return [
['name' => 'prodi', 'label' => 'Program studi', 'options' => $this->prodiOptions()],
['name' => 'status', 'label' => 'Status', 'options' => self::STATUS],
];
}
protected function columns(): array
{
return [
['label' => 'NIDN', 'key' => 'nidn'],
['label' => 'Nama', 'key' => 'nama'],
['label' => 'Program studi', 'key' => 'prodi'],
['label' => 'Jabatan', 'key' => 'jabatan'],
['label' => 'Status', 'key' => 'status', 'badge' => fn (array $r): string => match ($r['status']) {
'Aktif' => 'success', 'Cuti' => 'gold', default => 'accent',
}],
['label' => 'Bimbingan', 'key' => 'bimbingan', 'class' => 'num'],
];
}
protected function fields(?array $row): array
{
$prodi = $this->prodiOptions();
return [
['name' => 'nidn', 'label' => 'NIDN', 'rules' => ['required', 'digits:10'], 'attrs' => ['maxlength' => 10], 'section' => 'Identitas'],
['name' => 'nama', 'label' => 'Nama lengkap dan gelar', 'rules' => ['required', 'string', 'max:150'], 'section' => 'Identitas'],
['name' => 'email', 'label' => 'Email', 'type' => 'email', 'rules' => ['required', 'email', 'max:150'], 'section' => 'Identitas', 'span' => 'full'],
['name' => 'prodi', 'label' => 'Program studi', 'type' => 'select', 'options' => $prodi, 'rules' => ['required', Rule::in(array_keys($prodi))], 'section' => 'Kepegawaian'],
['name' => 'jabatan', 'label' => 'Jabatan fungsional', 'type' => 'select', 'options' => self::JABATAN, 'rules' => ['required', Rule::in(array_keys(self::JABATAN))], 'section' => 'Kepegawaian'],
['name' => 'status', 'label' => 'Status', 'type' => 'select', 'options' => self::STATUS, 'rules' => ['required', Rule::in(array_keys(self::STATUS))], 'section' => 'Kepegawaian'],
];
}
}
@@ -0,0 +1,50 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Prototype\ResourceController;
use App\Support\Prototype\Sample;
use Illuminate\Support\Collection;
class FakultasController extends ResourceController
{
protected function rows(): Collection
{
return Sample::fakultas();
}
protected function routeBase(): string
{
return 'admin.fakultas';
}
protected function names(): array
{
return ['singular' => 'Fakultas', 'plural' => 'Fakultas', 'description' => 'Daftar fakultas beserta dekan, jumlah program studi, dan jumlah mahasiswa.'];
}
protected function search(): array
{
return ['kode', 'nama', 'dekan'];
}
protected function columns(): array
{
return [
['label' => 'Kode', 'key' => 'kode'],
['label' => 'Nama fakultas', 'key' => 'nama'],
['label' => 'Dekan', 'key' => 'dekan'],
['label' => 'Prodi', 'key' => 'prodi', 'class' => 'num'],
['label' => 'Mahasiswa', 'value' => fn (array $r): string => number_format($r['mahasiswa'], 0, ',', '.'), 'class' => 'num'],
];
}
protected function fields(?array $row): array
{
return [
['name' => 'kode', 'label' => 'Kode fakultas', 'rules' => ['required', 'string', 'max:12'], 'hint' => 'Singkatan unik, contoh FT.'],
['name' => 'nama', 'label' => 'Nama fakultas', 'rules' => ['required', 'string', 'max:150']],
['name' => 'dekan', 'label' => 'Dekan', 'rules' => ['string', 'max:150'], 'optional' => true, 'span' => 'full'],
];
}
}
@@ -0,0 +1,68 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Prototype\ResourceController;
use App\Support\Prototype\Sample;
use Illuminate\Support\Carbon;
use Illuminate\Support\Collection;
use Illuminate\Validation\Rule;
class KalenderController extends ResourceController
{
private const KATEGORI = [
'Registrasi dan KRS' => 'Registrasi dan KRS', 'Perkuliahan' => 'Perkuliahan', 'Ujian' => 'Ujian',
'Libur' => 'Libur', 'Penilaian' => 'Penilaian', 'Administrasi' => 'Administrasi',
];
/** Kegiatan contoh diberi nomor urut sebagai pengenal. */
protected function rows(): Collection
{
return Sample::kalender()->sortBy('mulai')->values()->map(fn (array $e, int $i): array => ['id' => $i + 1, ...$e]);
}
protected function routeBase(): string
{
return 'admin.kalender';
}
protected function names(): array
{
return ['singular' => 'Kegiatan', 'plural' => 'Kelola kalender akademik', 'description' => 'Atur kegiatan pada kalender akademik yang tampil bagi seluruh pengguna.'];
}
protected function search(): array
{
return ['judul'];
}
protected function filters(): array
{
return [['name' => 'kategori', 'label' => 'Kategori', 'options' => self::KATEGORI]];
}
private function tanggal(?string $tanggal): string
{
return $tanggal ? Carbon::parse($tanggal)->locale('id')->isoFormat('D MMM YYYY') : '-';
}
protected function columns(): array
{
return [
['label' => 'Kegiatan', 'key' => 'judul'],
['label' => 'Kategori', 'key' => 'kategori', 'badge' => fn (array $r): string => $r['tone']],
['label' => 'Mulai', 'value' => fn (array $r): string => $this->tanggal($r['mulai'])],
['label' => 'Selesai', 'value' => fn (array $r): string => $this->tanggal($r['selesai'])],
];
}
protected function fields(?array $row): array
{
return [
['name' => 'judul', 'label' => 'Nama kegiatan', 'rules' => ['required', 'string', 'max:200'], 'span' => 'full'],
['name' => 'kategori', 'label' => 'Kategori', 'type' => 'select', 'options' => self::KATEGORI, 'rules' => ['required', Rule::in(array_keys(self::KATEGORI))], 'span' => 'full'],
['name' => 'mulai', 'label' => 'Tanggal mulai', 'type' => 'date', 'rules' => ['required', 'date']],
['name' => 'selesai', 'label' => 'Tanggal selesai', 'type' => 'date', 'rules' => ['date', 'after_or_equal:mulai'], 'optional' => true, 'hint' => 'Kosongkan bila kegiatan satu hari.'],
];
}
}
@@ -0,0 +1,35 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Support\Prototype\AdminData;
use App\Support\Prototype\Sample;
use Illuminate\Contracts\View\View;
class LaporanController extends Controller
{
public function __invoke(): View
{
$prodi = Sample::prodi();
$sebaran = AdminData::sebaranAngkatan();
$akreditasi = $prodi->countBy('akreditasi');
return view('admin.laporan', [
'tahun' => Sample::tahunAkademik()->firstWhere('aktif', true),
'totalMahasiswa' => (int) $prodi->sum('mahasiswa'),
'totalDosen' => Sample::dosen()->count(),
'totalProdi' => $prodi->count(),
'totalMataKuliah' => Sample::mataKuliah()->count(),
'angkatan' => AdminData::angkatan(),
'sebaran' => $sebaran,
'prodiLabels' => $prodi->pluck('kode')->all(),
'prodiData' => $prodi->pluck('mahasiswa')->all(),
'akreditasiLabels' => $akreditasi->keys()->all(),
'akreditasiData' => $akreditasi->values()->all(),
'totalPerAngkatan' => collect(AdminData::angkatan())->mapWithKeys(
fn (int $a): array => [$a => $sebaran->sum(fn (array $r): int => $r['angkatan'][$a])]
)->all(),
]);
}
}
@@ -0,0 +1,96 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Prototype\ResourceController;
use App\Support\Prototype\Sample;
use Illuminate\Support\Collection;
use Illuminate\Validation\Rule;
class MahasiswaController extends ResourceController
{
private const STATUS = ['Aktif' => 'Aktif', 'Cuti' => 'Cuti', 'Lulus' => 'Lulus', 'Drop out' => 'Drop out'];
protected function rows(): Collection
{
return Sample::mahasiswa();
}
protected function routeBase(): string
{
return 'admin.mahasiswa';
}
protected function names(): array
{
return ['singular' => 'Mahasiswa', 'plural' => 'Mahasiswa', 'description' => 'Data mahasiswa, status akademik, IPK, dan dosen pembimbing akademik.'];
}
protected function keyName(): string
{
return 'nim';
}
protected function search(): array
{
return ['nim', 'nama'];
}
/** @return array<string, string> */
private function prodiOptions(): array
{
return Sample::prodi()->pluck('nama', 'nama')->all();
}
protected function filters(): array
{
return [
['name' => 'prodi', 'label' => 'Program studi', 'options' => $this->prodiOptions()],
['name' => 'angkatan', 'label' => 'Angkatan', 'options' => Sample::mahasiswa()->pluck('angkatan')->unique()->sortDesc()->mapWithKeys(fn (int $a): array => [$a => (string) $a])->all()],
['name' => 'status', 'label' => 'Status', 'options' => self::STATUS],
];
}
protected function columns(): array
{
return [
['label' => 'NIM', 'key' => 'nim'],
['label' => 'Nama', 'key' => 'nama'],
['label' => 'Program studi', 'key' => 'prodi'],
['label' => 'Angkatan', 'key' => 'angkatan', 'class' => 'num'],
['label' => 'Status', 'key' => 'status', 'badge' => fn (array $r): string => match ($r['status']) {
'Aktif' => 'success', 'Lulus' => 'accent', 'Cuti' => 'gold', default => 'danger',
}],
['label' => 'IPK', 'value' => fn (array $r): string => number_format($r['ipk'], 2, ',', '.'), 'class' => 'num'],
];
}
protected function details(array $row): array
{
return [
'NIM' => $row['nim'],
'Nama' => $row['nama'],
'Program studi' => $row['prodi'],
'Angkatan' => $row['angkatan'],
'Status' => $row['status'],
'IPK' => number_format($row['ipk'], 2, ',', '.'),
'SKS ditempuh' => $row['sks'],
'Dosen pembimbing akademik' => $row['pa'],
];
}
protected function fields(?array $row): array
{
$prodi = $this->prodiOptions();
$dosen = Sample::dosen()->pluck('nama', 'nama')->all();
return [
['name' => 'nim', 'label' => 'NIM', 'rules' => ['required', 'string', 'max:20'], 'section' => 'Identitas'],
['name' => 'nama', 'label' => 'Nama lengkap', 'rules' => ['required', 'string', 'max:150'], 'section' => 'Identitas'],
['name' => 'prodi', 'label' => 'Program studi', 'type' => 'select', 'options' => $prodi, 'rules' => ['required', Rule::in(array_keys($prodi))], 'section' => 'Akademik'],
['name' => 'angkatan', 'label' => 'Angkatan', 'type' => 'number', 'rules' => ['required', 'integer', 'between:2000,2100'], 'attrs' => ['min' => 2000, 'max' => 2100], 'section' => 'Akademik'],
['name' => 'status', 'label' => 'Status', 'type' => 'select', 'options' => self::STATUS, 'rules' => ['required', Rule::in(array_keys(self::STATUS))], 'section' => 'Akademik'],
['name' => 'pa', 'label' => 'Dosen pembimbing akademik', 'type' => 'select', 'options' => $dosen, 'rules' => ['required', Rule::in(array_keys($dosen))], 'section' => 'Akademik'],
];
}
}
@@ -0,0 +1,85 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Prototype\ResourceController;
use App\Support\Prototype\Sample;
use Illuminate\Support\Collection;
use Illuminate\Validation\Rule;
class MataKuliahController extends ResourceController
{
private const SIFAT = ['Wajib' => 'Wajib', 'Pilihan' => 'Pilihan'];
protected function rows(): Collection
{
return Sample::mataKuliah();
}
protected function routeBase(): string
{
return 'admin.mata-kuliah';
}
protected function names(): array
{
return ['singular' => 'Mata kuliah', 'plural' => 'Mata kuliah', 'description' => 'Katalog mata kuliah beserta SKS, semester, dan sifatnya.'];
}
protected function keyName(): string
{
return 'kode';
}
protected function search(): array
{
return ['kode', 'nama'];
}
/** @return array<string, string> */
private function prodiOptions(): array
{
return Sample::mataKuliah()->pluck('prodi')->unique()->sort()->mapWithKeys(fn (string $p): array => [$p => $p])->all();
}
/** @return array<int, string> */
private function semesterOptions(): array
{
return collect(range(1, 8))->mapWithKeys(fn (int $s): array => [$s => 'Semester '.$s])->all();
}
protected function filters(): array
{
return [
['name' => 'prodi', 'label' => 'Program studi', 'options' => $this->prodiOptions()],
['name' => 'semester', 'label' => 'Semester', 'options' => $this->semesterOptions()],
['name' => 'sifat', 'label' => 'Sifat', 'options' => self::SIFAT],
];
}
protected function columns(): array
{
return [
['label' => 'Kode', 'key' => 'kode'],
['label' => 'Mata kuliah', 'key' => 'nama'],
['label' => 'SKS', 'key' => 'sks', 'class' => 'num'],
['label' => 'Semester', 'key' => 'semester', 'class' => 'num'],
['label' => 'Sifat', 'key' => 'sifat', 'badge' => fn (array $r): string => $r['sifat'] === 'Wajib' ? 'accent' : 'gold'],
['label' => 'Program studi', 'key' => 'prodi'],
];
}
protected function fields(?array $row): array
{
$prodi = $this->prodiOptions();
return [
['name' => 'kode', 'label' => 'Kode mata kuliah', 'rules' => ['required', 'string', 'max:16']],
['name' => 'nama', 'label' => 'Nama mata kuliah', 'rules' => ['required', 'string', 'max:150']],
['name' => 'sks', 'label' => 'SKS', 'type' => 'number', 'rules' => ['required', 'integer', 'between:1,6'], 'attrs' => ['min' => 1, 'max' => 6]],
['name' => 'semester', 'label' => 'Semester', 'type' => 'select', 'options' => $this->semesterOptions(), 'rules' => ['required', Rule::in(range(1, 8))]],
['name' => 'sifat', 'label' => 'Sifat', 'type' => 'select', 'options' => self::SIFAT, 'rules' => ['required', Rule::in(array_keys(self::SIFAT))]],
['name' => 'prodi', 'label' => 'Program studi', 'type' => 'select', 'options' => $prodi, 'rules' => ['required', Rule::in(array_keys($prodi))]],
];
}
}
@@ -0,0 +1,68 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Prototype\ResourceController;
use App\Support\Prototype\AdminData;
use Illuminate\Support\Collection;
use Illuminate\Validation\Rule;
class OperatorController extends ResourceController
{
private const STATUS = ['Aktif' => 'Aktif', 'Cuti' => 'Cuti', 'Nonaktif' => 'Nonaktif'];
protected function rows(): Collection
{
return AdminData::operator();
}
protected function routeBase(): string
{
return 'admin.operator';
}
protected function names(): array
{
return ['singular' => 'Operator', 'plural' => 'Operator', 'description' => 'Staf operator akademik di tingkat universitas dan fakultas.'];
}
protected function keyName(): string
{
return 'nip';
}
protected function search(): array
{
return ['nip', 'nama', 'unit', 'email'];
}
protected function filters(): array
{
return [['name' => 'status', 'label' => 'Status', 'options' => self::STATUS]];
}
protected function columns(): array
{
return [
['label' => 'NIP', 'key' => 'nip'],
['label' => 'Nama', 'key' => 'nama'],
['label' => 'Unit kerja', 'key' => 'unit'],
['label' => 'Jabatan', 'key' => 'jabatan'],
['label' => 'Status', 'key' => 'status', 'badge' => fn (array $r): string => match ($r['status']) {
'Aktif' => 'success', 'Cuti' => 'gold', default => 'danger',
}],
];
}
protected function fields(?array $row): array
{
return [
['name' => 'nip', 'label' => 'NIP', 'rules' => ['required', 'digits:18'], 'attrs' => ['maxlength' => 18]],
['name' => 'nama', 'label' => 'Nama lengkap', 'rules' => ['required', 'string', 'max:150']],
['name' => 'email', 'label' => 'Email', 'type' => 'email', 'rules' => ['required', 'email', 'max:150']],
['name' => 'unit', 'label' => 'Unit kerja', 'rules' => ['required', 'string', 'max:150']],
['name' => 'jabatan', 'label' => 'Jabatan', 'rules' => ['required', 'string', 'max:100']],
['name' => 'status', 'label' => 'Status', 'type' => 'select', 'options' => self::STATUS, 'rules' => ['required', Rule::in(array_keys(self::STATUS))]],
];
}
}
@@ -0,0 +1,77 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Prototype\ResourceController;
use App\Support\Prototype\Sample;
use Illuminate\Support\Carbon;
use Illuminate\Support\Collection;
use Illuminate\Validation\Rule;
class PengumumanController extends ResourceController
{
private const AUDIENS = ['Semua pengguna' => 'Semua pengguna', 'Mahasiswa' => 'Mahasiswa', 'Dosen' => 'Dosen', 'Operator' => 'Operator', 'Admin' => 'Admin'];
private const STATUS = ['Terbit' => 'Terbit', 'Draf' => 'Draf'];
protected function rows(): Collection
{
return Sample::pengumuman()->sortByDesc('tanggal')->values();
}
protected function routeBase(): string
{
return 'admin.pengumuman';
}
protected function names(): array
{
return ['singular' => 'Pengumuman', 'plural' => 'Kelola pengumuman', 'description' => 'Tulis, terbitkan, dan arsipkan pengumuman untuk pengguna sistem.'];
}
protected function search(): array
{
return ['judul', 'penulis'];
}
protected function filters(): array
{
return [
['name' => 'audiens', 'label' => 'Audiens', 'options' => self::AUDIENS],
['name' => 'status', 'label' => 'Status', 'options' => self::STATUS],
];
}
protected function columns(): array
{
return [
['label' => 'Judul', 'key' => 'judul'],
['label' => 'Audiens', 'key' => 'audiens', 'badge' => fn (array $r): string => $r['audiens'] === 'Semua pengguna' ? 'accent' : 'gold'],
['label' => 'Status', 'key' => 'status', 'badge' => fn (array $r): string => $r['status'] === 'Terbit' ? 'success' : 'neutral'],
['label' => 'Penulis', 'key' => 'penulis'],
['label' => 'Tanggal', 'value' => fn (array $r): string => Carbon::parse($r['tanggal'])->locale('id')->isoFormat('D MMM YYYY')],
];
}
protected function details(array $row): array
{
return [
'Judul' => $row['judul'],
'Audiens' => $row['audiens'],
'Status' => $row['status'],
'Penulis' => $row['penulis'],
'Tanggal' => Carbon::parse($row['tanggal'])->locale('id')->isoFormat('dddd, D MMMM YYYY'),
'Isi' => $row['isi'],
];
}
protected function fields(?array $row): array
{
return [
['name' => 'judul', 'label' => 'Judul', 'rules' => ['required', 'string', 'max:200'], 'span' => 'full'],
['name' => 'audiens', 'label' => 'Audiens', 'type' => 'select', 'options' => self::AUDIENS, 'rules' => ['required', Rule::in(array_keys(self::AUDIENS))]],
['name' => 'status', 'label' => 'Status', 'type' => 'select', 'options' => self::STATUS, 'rules' => ['required', Rule::in(array_keys(self::STATUS))], 'hint' => 'Draf tidak tampil bagi pengguna.'],
['name' => 'isi', 'label' => 'Isi pengumuman', 'type' => 'textarea', 'rules' => ['required', 'string', 'max:5000'], 'rows' => 8],
];
}
}
@@ -0,0 +1,73 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Prototype\ResourceController;
use App\Support\Prototype\Sample;
use Illuminate\Support\Collection;
use Illuminate\Validation\Rule;
class ProgramStudiController extends ResourceController
{
private const JENJANG = ['D3' => 'D3', 'S1' => 'S1', 'S2' => 'S2', 'S3' => 'S3'];
private const AKREDITASI = ['Unggul' => 'Unggul', 'Baik Sekali' => 'Baik Sekali', 'Baik' => 'Baik'];
protected function rows(): Collection
{
return Sample::prodi();
}
protected function routeBase(): string
{
return 'admin.program-studi';
}
protected function names(): array
{
return ['singular' => 'Program studi', 'plural' => 'Program studi', 'description' => 'Program studi per fakultas, lengkap dengan jenjang, akreditasi, dan ketua program studi.'];
}
protected function search(): array
{
return ['kode', 'nama', 'kaprodi'];
}
protected function filters(): array
{
return [
['name' => 'fakultas', 'label' => 'Fakultas', 'options' => Sample::fakultas()->pluck('nama', 'nama')->all()],
['name' => 'jenjang', 'label' => 'Jenjang', 'options' => self::JENJANG],
['name' => 'akreditasi', 'label' => 'Akreditasi', 'options' => self::AKREDITASI],
];
}
protected function columns(): array
{
return [
['label' => 'Kode', 'key' => 'kode'],
['label' => 'Program studi', 'key' => 'nama'],
['label' => 'Fakultas', 'key' => 'fakultas'],
['label' => 'Jenjang', 'key' => 'jenjang'],
['label' => 'Akreditasi', 'key' => 'akreditasi', 'badge' => fn (array $r): string => match ($r['akreditasi']) {
'Unggul' => 'success', 'Baik Sekali' => 'accent', default => 'gold',
}],
['label' => 'Kaprodi', 'key' => 'kaprodi'],
['label' => 'Mahasiswa', 'value' => fn (array $r): string => number_format($r['mahasiswa'], 0, ',', '.'), 'class' => 'num'],
];
}
protected function fields(?array $row): array
{
$fakultas = Sample::fakultas()->pluck('nama', 'nama')->all();
return [
['name' => 'fakultas', 'label' => 'Fakultas', 'type' => 'select', 'options' => $fakultas, 'rules' => ['required', Rule::in(array_keys($fakultas))], 'span' => 'full'],
['name' => 'kode', 'label' => 'Kode program studi', 'rules' => ['required', 'string', 'max:12']],
['name' => 'nama', 'label' => 'Nama program studi', 'rules' => ['required', 'string', 'max:150']],
['name' => 'jenjang', 'label' => 'Jenjang', 'type' => 'select', 'options' => self::JENJANG, 'rules' => ['required', Rule::in(array_keys(self::JENJANG))]],
['name' => 'akreditasi', 'label' => 'Akreditasi', 'type' => 'select', 'options' => self::AKREDITASI, 'rules' => ['required', Rule::in(array_keys(self::AKREDITASI))]],
['name' => 'kaprodi', 'label' => 'Ketua program studi', 'rules' => ['string', 'max:150'], 'optional' => true, 'span' => 'full'],
];
}
}
@@ -0,0 +1,65 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Prototype\ResourceController;
use App\Support\Prototype\Sample;
use Illuminate\Support\Collection;
use Illuminate\Validation\Rule;
class RuangController extends ResourceController
{
private const JENIS = ['Ruang kelas' => 'Ruang kelas', 'Laboratorium' => 'Laboratorium', 'Aula' => 'Aula'];
protected function rows(): Collection
{
return Sample::ruang();
}
protected function routeBase(): string
{
return 'admin.ruang';
}
protected function names(): array
{
return ['singular' => 'Ruang', 'plural' => 'Ruang', 'description' => 'Ruang kuliah, laboratorium, dan aula yang dapat dipakai untuk penjadwalan.'];
}
protected function keyName(): string
{
return 'kode';
}
protected function search(): array
{
return ['kode', 'nama', 'gedung'];
}
protected function filters(): array
{
return [['name' => 'jenis', 'label' => 'Jenis ruang', 'options' => self::JENIS]];
}
protected function columns(): array
{
return [
['label' => 'Kode', 'key' => 'kode'],
['label' => 'Nama ruang', 'key' => 'nama'],
['label' => 'Gedung', 'key' => 'gedung'],
['label' => 'Kapasitas', 'key' => 'kapasitas', 'class' => 'num'],
['label' => 'Jenis', 'key' => 'jenis', 'badge' => fn (array $r): string => $r['jenis'] === 'Laboratorium' ? 'gold' : 'accent'],
];
}
protected function fields(?array $row): array
{
return [
['name' => 'kode', 'label' => 'Kode ruang', 'rules' => ['required', 'string', 'max:16']],
['name' => 'nama', 'label' => 'Nama ruang', 'rules' => ['required', 'string', 'max:100']],
['name' => 'gedung', 'label' => 'Gedung', 'rules' => ['required', 'string', 'max:100']],
['name' => 'kapasitas', 'label' => 'Kapasitas', 'type' => 'number', 'rules' => ['required', 'integer', 'between:1,1000'], 'attrs' => ['min' => 1, 'max' => 1000], 'suffix' => 'orang'],
['name' => 'jenis', 'label' => 'Jenis ruang', 'type' => 'select', 'options' => self::JENIS, 'rules' => ['required', Rule::in(array_keys(self::JENIS))], 'span' => 'full'],
];
}
}
@@ -0,0 +1,67 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Prototype\ResourceController;
use App\Support\Prototype\Sample;
use Illuminate\Support\Carbon;
use Illuminate\Support\Collection;
class TahunAkademikController extends ResourceController
{
protected function rows(): Collection
{
return Sample::tahunAkademik()->map(fn (array $r): array => [...$r, 'status' => $r['aktif'] ? 'Aktif' : 'Tidak aktif']);
}
protected function routeBase(): string
{
return 'admin.tahun-akademik';
}
protected function names(): array
{
return ['singular' => 'Tahun akademik', 'plural' => 'Tahun akademik', 'description' => 'Periode perkuliahan beserta jadwal pengisian KRS dan batas input nilai. Hanya satu tahun akademik yang aktif.'];
}
protected function search(): array
{
return ['kode', 'nama'];
}
protected function filters(): array
{
return [['name' => 'status', 'label' => 'Status', 'options' => ['Aktif' => 'Aktif', 'Tidak aktif' => 'Tidak aktif']]];
}
private function tanggal(?string $tanggal): string
{
return $tanggal ? Carbon::parse($tanggal)->locale('id')->isoFormat('D MMM YYYY') : '-';
}
protected function columns(): array
{
return [
['label' => 'Kode', 'key' => 'kode'],
['label' => 'Tahun akademik', 'key' => 'nama'],
['label' => 'Perkuliahan', 'value' => fn (array $r): string => $this->tanggal($r['mulai']).' - '.$this->tanggal($r['selesai'])],
['label' => 'Pengisian KRS', 'value' => fn (array $r): string => $this->tanggal($r['krs_mulai']).' - '.$this->tanggal($r['krs_selesai'])],
['label' => 'Batas nilai', 'value' => fn (array $r): string => $this->tanggal($r['nilai_selesai'])],
['label' => 'Status', 'key' => 'status', 'badge' => fn (array $r): ?string => $r['aktif'] ? 'success' : null],
];
}
protected function fields(?array $row): array
{
return [
['name' => 'kode', 'label' => 'Kode', 'rules' => ['required', 'string', 'max:8'], 'hint' => 'Tahun diikuti 1 (ganjil) atau 2 (genap), contoh 20261.', 'section' => 'Identitas'],
['name' => 'nama', 'label' => 'Nama tahun akademik', 'rules' => ['required', 'string', 'max:40'], 'hint' => 'Contoh 2026/2027 Ganjil.', 'section' => 'Identitas'],
['name' => 'aktif', 'label' => 'Jadikan tahun akademik aktif', 'type' => 'checkbox', 'section' => 'Identitas', 'span' => 'full'],
['name' => 'mulai', 'label' => 'Perkuliahan mulai', 'type' => 'date', 'rules' => ['required', 'date'], 'section' => 'Jadwal'],
['name' => 'selesai', 'label' => 'Perkuliahan selesai', 'type' => 'date', 'rules' => ['required', 'date', 'after:mulai'], 'section' => 'Jadwal'],
['name' => 'krs_mulai', 'label' => 'Pengisian KRS mulai', 'type' => 'date', 'rules' => ['required', 'date'], 'section' => 'Jadwal'],
['name' => 'krs_selesai', 'label' => 'Pengisian KRS selesai', 'type' => 'date', 'rules' => ['required', 'date', 'after_or_equal:krs_mulai'], 'section' => 'Jadwal'],
['name' => 'nilai_selesai', 'label' => 'Batas akhir input nilai', 'type' => 'date', 'rules' => ['required', 'date', 'after:selesai'], 'section' => 'Jadwal'],
];
}
}