Commit awal: prototipe UI SIAKAD Untan
This commit is contained in:
@@ -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'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user