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