- Butang Padam dalam senarai pengguna (dengan pengesahan) - Tidak boleh padam akaun sendiri — dipapar '(akaun anda)' - Tidak boleh padam pengguna yang telah mencatat rekod kehadiran (disokong FK dicatat_oleh_user_id di peringkat DB) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
65 lines
2.6 KiB
PHP
65 lines
2.6 KiB
PHP
@extends('layouts.app')
|
|
|
|
@section('tajuk', 'Senarai Pengguna')
|
|
|
|
@section('kandungan')
|
|
<div class="kad">
|
|
<div style="display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:0.5rem;">
|
|
<h1 class="mb-0">Pengguna</h1>
|
|
<a href="{{ route('pengguna.create') }}" class="btn">+ Daftar Pengguna</a>
|
|
</div>
|
|
</div>
|
|
|
|
@if ($errors->any())
|
|
<div class="makluman makluman-ralat">{{ $errors->first() }}</div>
|
|
@endif
|
|
|
|
@if ($pengguna->isEmpty())
|
|
<div class="kad teks-tengah">
|
|
<p>Tiada pengguna lagi.</p>
|
|
</div>
|
|
@else
|
|
<div class="kad" style="overflow-x:auto; padding:0;">
|
|
<table class="jadual">
|
|
<thead>
|
|
<tr>
|
|
<th>Nama</th>
|
|
<th>E-mel</th>
|
|
<th>Peranan</th>
|
|
<th>DUN</th>
|
|
<th>Tindakan</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach ($pengguna as $p)
|
|
<tr>
|
|
<td>{{ $p->name }}</td>
|
|
<td>{{ $p->email }}</td>
|
|
<td>
|
|
{{ match ($p->role) {
|
|
'superadmin' => 'Superadmin',
|
|
'admin' => 'Admin DUN',
|
|
default => $p->role,
|
|
} }}
|
|
</td>
|
|
<td>{{ $p->dun ? $p->dun->code . ' — ' . $p->dun->nama : '-' }}</td>
|
|
<td>
|
|
@if ($p->id === auth()->id())
|
|
<span class="teks-kecil">(akaun anda)</span>
|
|
@else
|
|
<form method="POST" action="{{ route('pengguna.destroy', $p) }}" style="margin:0"
|
|
onsubmit="return confirm('Padam pengguna {{ $p->name }}? Tindakan ini tidak boleh dikembalikan.');">
|
|
@csrf
|
|
@method('DELETE')
|
|
<button type="submit" class="btn btn-kecil btn-merah">Padam</button>
|
|
</form>
|
|
@endif
|
|
</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
@endif
|
|
@endsection
|