[Mahasiswa] Pembaruan Laman dan Deleted Pengumuman
This commit is contained in:
@@ -43,7 +43,6 @@ class DashboardController extends Controller
|
||||
'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(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
<?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],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user