diff --git a/app/Http/Controllers/Admin/MasterIndukController.php b/app/Http/Controllers/Admin/MasterIndukController.php new file mode 100644 index 0000000..9968453 --- /dev/null +++ b/app/Http/Controllers/Admin/MasterIndukController.php @@ -0,0 +1,31 @@ +validate([ + 'nomor_induk' => 'required|unique:master_induks,nomor_induk', + 'role' => 'required|in:siswa,guru', + 'nama_pemilik' => 'required|string', + ]); + + MasterInduk::create($request->all()); + + return back()->with('success', 'Data Induk berhasil ditambahkan. User dengan NIP/NISN ini sekarang bisa mendaftar.'); + } + + // Menghapus Data + public function destroy($id) + { + MasterInduk::findOrFail($id)->delete(); + return back()->with('success', 'Data Induk dihapus.'); + } +} diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index f30097c..9ddca0b 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -4,6 +4,7 @@ use App\Http\Controllers\Controller; use App\Models\User; +use App\Models\MasterInduk; use Illuminate\Http\Request; use Illuminate\Support\Facades\Hash; @@ -11,10 +12,14 @@ class UserController extends Controller { public function index() { - $semuaSiswa = User::whereIn('role', ['siswa', 'guru', 'penjaga perpus'])->latest()->get(); + $users = User::orderBy('created_at', 'desc')->paginate(10); + + $whitelists = MasterInduk::orderBy('created_at', 'desc')->get(); + return view('admin.pengguna.index', [ - 'pageTitle' => 'Manajemen Pengguna', - 'semuaSiswa' => $semuaSiswa + 'pageTitle' => 'Daftar Pengguna', + 'users' => $users, + 'whitelists' => $whitelists ]); } diff --git a/app/Models/MasterInduk.php b/app/Models/MasterInduk.php new file mode 100644 index 0000000..ec40017 --- /dev/null +++ b/app/Models/MasterInduk.php @@ -0,0 +1,13 @@ +id(); + $table->string('nomor_induk')->unique(); + $table->string('nama_pemilik'); + $table->string('role'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('master_induks'); + } +}; diff --git a/resources/views/admin/pengguna/index.blade.php b/resources/views/admin/pengguna/index.blade.php index 1a0e8a1..d8d5f70 100644 --- a/resources/views/admin/pengguna/index.blade.php +++ b/resources/views/admin/pengguna/index.blade.php @@ -1,116 +1,194 @@ - @section('page-title', $pageTitle) + @section('page-title', content: 'Manajemen Pengguna') +
-
-
-
Daftar Semua Pengguna
- - Tambah Pengguna - +
+

{{ $pageTitle }}

-
-
- - - - - - - - - - - - @forelse($semuaSiswa as $siswa) - - - - - - - - @empty - - - - @endforelse - -
NoNama LengkapEmailRoleAksi
{{ $loop->iteration }}{{ $siswa['nama_lengkap'] }}{{ $siswa['email'] }} - @if($siswa['role'] == 'penjaga perpus') - {{ Str::title($siswa['role']) }} - @else - {{ Str::title($siswa['role']) }} - @endif - - -
Tidak ada data pengguna.
+ +
+
+
Daftar Pengguna Aktif
+
+
+
+ + + + + + + + + + + + + @forelse($users as $index => $user) + + + + + + + + + @empty + + + + @endforelse + +
NoNama LengkapEmailRoleNomor IndukAksi
{{ $index + 1 }}{{ $user->name }}{{ $user->email }} + + {{ ucfirst($user->role) }} + + + {{ $user->nomor_induk ?? '-' }} + +
+ + Edit + +
+ @csrf + @method('DELETE') + +
+
+
Belum ada pengguna terdaftar.
+ + {{-- Pagination --}} +
+ {{ $users->links() }} +
+
+ +
+ +
+
+

+ Data Induk (Whitelist) +

+

Daftar NIP/NISN yang diizinkan untuk mendaftar.

+
+ + +
+ +
+
+
+ + + + + + + + + + + + + @forelse($whitelists as $index => $item) + + + + + + + + + @empty + + + + @endforelse + +
NoNIP / NISNNama PemilikRoleStatus AkunAksi
{{ $index + 1 }}{{ $item->nomor_induk }}{{ $item->nama_pemilik }} + + {{ ucfirst($item->role) }} + + + {{-- Cek apakah user sudah daftar pakai NIP ini --}} + @php + $isRegistered = \App\Models\User::where('nomor_induk', $item->nomor_induk)->exists(); + @endphp + + @if($isRegistered) + + Terdaftar + + @else + + Belum Daftar + + @endif + +
+ @csrf + @method('DELETE') + +
+
+ Belum ada data whitelist. Silakan tambah data. +
+
+
+
+
-