[Superuser] Integrasi Pertama ke Database
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user