[Superuser] Integrasi Pertama ke Database

This commit is contained in:
Ariyutta
2026-11-11 18:26:23 +07:00
parent eba6ab77b4
commit c12c634b4f
47 changed files with 2322 additions and 109 deletions
+26 -2
View File
@@ -2,13 +2,37 @@
namespace App\Http\Controllers;
use App\Models\Legacy\Account;
use App\Support\Legacy\AcademicCalendar;
use App\Support\Prototype\Sample;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
/** Kalender akademik bersama. Akun DB lama: kegiatan asli t_kalender_kegiatan per periode; akun demo: contoh. */
class KalenderController extends Controller
{
public function __invoke(): View
public function __invoke(Request $request, AcademicCalendar $calendar): View
{
return view('kalender.index', ['tahun' => Sample::TAHUN_AKTIF, 'events' => Sample::kalender()]);
if (! $request->user() instanceof Account) {
return view('kalender.index', ['tahun' => Sample::TAHUN_AKTIF, 'events' => Sample::kalender()]);
}
$periods = $calendar->periods();
$periode = $periods->has($request->integer('periode')) ? $request->integer('periode') : $calendar->currentPeriod($periods);
$events = $periode === null ? collect() : $calendar->schedule($periode)->map(fn (array $e): array => [
'judul' => $e['keterangan'] !== '' ? $e['keterangan'] : $e['jenis'],
'kategori' => $e['jenis'],
'tone' => str_contains(mb_strtolower($e['jenis']), 'libur') ? 'gold' : 'neutral',
'mulai' => $e['mulai'],
'selesai' => $e['selesai'] === $e['mulai'] ? null : $e['selesai'],
]);
return view('kalender.index', [
'tahun' => $periode === null ? '' : $periods[$periode],
'events' => $events,
'periods' => $periods,
'periode' => $periode,
]);
}
}