[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
@@ -2,6 +2,8 @@
namespace App\Http\Controllers;
use App\Enums\Role;
use App\Models\Legacy\Account;
use App\Support\Prototype\Sample;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Collection;
@@ -10,17 +12,28 @@ class PengumumanController extends Controller
{
public function index(): View
{
$this->closedForLegacySuperuser();
return view('pengumuman.index', ['items' => $this->visible()]);
}
public function show(int $id): View
{
$this->closedForLegacySuperuser();
$item = $this->visible()->firstWhere('id', $id);
abort_if($item === null, 404);
return view('pengumuman.show', ['item' => $item]);
}
/** Pengumuman belum punya sumber data di DB lama: Superuser akun DB lama tidak melihat contoh (menunya juga disembunyikan). */
private function closedForLegacySuperuser(): void
{
$user = auth()->user();
abort_if($user instanceof Account && $user->role === Role::Superuser, 404);
}
/** Pengumuman terbit yang ditujukan ke semua pengguna atau ke role pengguna ini. @return Collection<int, array<string, mixed>> */
private function visible(): Collection
{