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,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],
];
}
}