diff --git a/app/Http/Controllers/Admin/AdminController.php b/app/Http/Controllers/Admin/AdminController.php
index f05d4b7..63a8a45 100644
--- a/app/Http/Controllers/Admin/AdminController.php
+++ b/app/Http/Controllers/Admin/AdminController.php
@@ -15,7 +15,7 @@ public function dashboard(){
$totalSiswa = Siswa::count();
$totalKelas = Kelas::count();
$totalMapel = Mapel::count();
- $chartData = Kelas::withCount('siswas')->get();
+ $chartData = Kelas::withCount('siswa')->get();
$latestChallenges = Challenge::latest()->take(3)->get();
return view('admin.dashboard', compact('totalGuru','totalSiswa','totalKelas','totalMapel','chartData','latestChallenges'));
}
diff --git a/app/Http/Controllers/Admin/GuruController.php b/app/Http/Controllers/Admin/GuruController.php
index e69de29..922b3e2 100644
--- a/app/Http/Controllers/Admin/GuruController.php
+++ b/app/Http/Controllers/Admin/GuruController.php
@@ -0,0 +1,124 @@
+has('search')) {
+ $search = $request->search;
+ $query->where('nama', 'like', "%$search%")
+ ->orWhere('nip', 'like', "%$search%");
+ }
+
+ // SHOW PER PAGE
+ $perPage = $request->get('perPage', 10);
+
+ $gurus = $query->paginate($perPage)->appends($request->all());
+
+ return view('admin.guru.index', compact('gurus'));
+}
+
+
+ /**
+ * Show the form for creating a new resource.
+ */
+ public function create()
+ {
+ return view('admin.guru.create');
+ }
+
+ /**
+ * Store a newly created resource in storage.
+ */
+ public function store(Request $request)
+ {
+ $validated = $request->validate([
+ 'nip' => 'required|string|max:30|unique:gurus,nip',
+ 'nama' => 'required|string|max:100',
+ 'password' => 'required|string|min:6',
+ ], [
+ 'nip.required' => 'NIP wajib diisi',
+ 'nip.unique' => 'NIP sudah terdaftar',
+ 'nama.required' => 'Nama wajib diisi',
+ 'password.required' => 'Password wajib diisi',
+ 'password.min' => 'Password minimal 6 karakter',
+ ]);
+
+ Guru::create([
+ 'nip' => $validated['nip'],
+ 'nama' => $validated['nama'],
+ 'password' => Hash::make($validated['password']),
+ ]);
+
+ return redirect()->route('admin.guru.index')
+ ->with('success', 'Data guru berhasil ditambahkan!');
+ }
+
+ /**
+ * Display the specified resource.
+ */
+ public function show(string $nip)
+ {
+ $guru = Guru::findOrFail($nip);
+ return view('admin.guru.show', compact('guru'));
+ }
+
+ /**
+ * Show the form for editing the specified resource.
+ */
+ public function edit(string $nip)
+ {
+ $guru = Guru::findOrFail($nip);
+ return view('admin.guru.edit', compact('guru'));
+ }
+
+ /**
+ * Update the specified resource in storage.
+ */
+ public function update(Request $request, string $nip)
+ {
+ $guru = Guru::findOrFail($nip);
+
+ $validated = $request->validate([
+ 'nama' => 'required|string|max:100',
+ 'password' => 'nullable|string|min:6',
+ ], [
+ 'nama.required' => 'Nama wajib diisi',
+ 'password.min' => 'Password minimal 6 karakter',
+ ]);
+
+ $guru->nama = $validated['nama'];
+
+ // Update password hanya jika diisi
+ if ($request->filled('password')) {
+ $guru->password = Hash::make($validated['password']);
+ }
+
+ $guru->save();
+
+ return redirect()->route('admin.guru.index')
+ ->with('success', 'Data guru berhasil diupdate!');
+ }
+
+ /**
+ * Remove the specified resource from storage.
+ */
+ public function destroy(string $nip)
+ {
+ $guru = Guru::findOrFail($nip);
+ $guru->delete();
+
+ return redirect()->route('admin.guru.index')
+ ->with('success', 'Data guru berhasil dihapus!');
+ }
+}
\ No newline at end of file
diff --git a/app/Models/Guru.php b/app/Models/Guru.php
index d13de0c..1a94554 100644
--- a/app/Models/Guru.php
+++ b/app/Models/Guru.php
@@ -6,7 +6,7 @@
class Guru extends Model
{
- protected $table = 'guru'; // INI PENTING!
+ protected $table = 'gurus';
protected $primaryKey = 'nip';
@@ -17,7 +17,10 @@ class Guru extends Model
protected $fillable = [
'nip',
'nama',
- 'email',
'password'
];
-}
+
+ protected $hidden = [
+ 'password',
+ ];
+}
\ No newline at end of file
diff --git a/app/Models/Kelas.php b/app/Models/Kelas.php
index 438617d..1d56693 100644
--- a/app/Models/Kelas.php
+++ b/app/Models/Kelas.php
@@ -19,4 +19,10 @@ class Kelas extends Model
'nama_kelas',
'tingkat',
];
+
+ public function siswa()
+ {
+ return $this->hasMany(Siswa::class, 'id_kelas', 'id_kelas');
+ }
+
}
\ No newline at end of file
diff --git a/app/Models/Siswa.php b/app/Models/Siswa.php
index f0518be..ec19a81 100644
--- a/app/Models/Siswa.php
+++ b/app/Models/Siswa.php
@@ -27,4 +27,10 @@ class Siswa extends Model
protected $hidden = [
'password',
];
+
+ public function kelas()
+ {
+ return $this->belongsTo(Kelas::class, 'id_kelas', 'id_kelas');
+ }
+
}
\ No newline at end of file
diff --git a/public/images/icon/main/add.png b/public/images/icon/main/add.png
new file mode 100644
index 0000000..7eab5a6
Binary files /dev/null and b/public/images/icon/main/add.png differ
diff --git a/public/images/icon/main/del.png b/public/images/icon/main/del.png
new file mode 100644
index 0000000..9422bb4
Binary files /dev/null and b/public/images/icon/main/del.png differ
diff --git a/public/images/icon/main/delete.png b/public/images/icon/main/delete.png
new file mode 100644
index 0000000..2abab59
Binary files /dev/null and b/public/images/icon/main/delete.png differ
diff --git a/public/images/icon/main/download.png b/public/images/icon/main/download.png
new file mode 100644
index 0000000..7c17801
Binary files /dev/null and b/public/images/icon/main/download.png differ
diff --git a/public/images/icon/main/edit.png b/public/images/icon/main/edit.png
new file mode 100644
index 0000000..b86b617
Binary files /dev/null and b/public/images/icon/main/edit.png differ
diff --git a/public/images/icon/main/search.png b/public/images/icon/main/search.png
new file mode 100644
index 0000000..33fabf9
Binary files /dev/null and b/public/images/icon/main/search.png differ
diff --git a/resources/views/admin/guru/create.blade.php b/resources/views/admin/guru/create.blade.php
new file mode 100644
index 0000000..e69de29
diff --git a/resources/views/admin/guru/edit.blade.php b/resources/views/admin/guru/edit.blade.php
new file mode 100644
index 0000000..e69de29
diff --git a/resources/views/admin/guru/index.blade.php b/resources/views/admin/guru/index.blade.php
index 8425e4c..771fd01 100644
--- a/resources/views/admin/guru/index.blade.php
+++ b/resources/views/admin/guru/index.blade.php
@@ -1,31 +1,309 @@
@extends('admin.layouts.app')
-@section('title','Daftar Guru')
+
+@section('title', 'Daftar Guru')
+
@section('content')
-
-
-
Daftar Guru
-
Tambah Guru
-
-
- # Nama Email Aksi
-
- @foreach($gurus as $g)
-
- {{ $loop->iteration }}
- {{ $g->name }}
- {{ $g->email }}
-
- Edit
-
-
-
- @endforeach
-
-
+
+
+
DAFTAR GURU
+
+
+
+
+
+
+
+
+ Tambah Data
+
+
+
+
+ Download PDF
+
+
+
+
+ Download Excel
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @forelse($gurus as $index => $guru)
+
+ {{ $gurus->firstItem() + $index }}
+ {{ $guru->nama }}
+ {{ $guru->nip }}
+ ********
+
+
+
+
+
+
+
+
+
+
+ @empty
+
+ Belum ada data guru
+
+ @endforelse
+
+
+
+
+ {{ $gurus->links() }}
+
- {{ $gurus->links() }}
+
+{{-- MODAL TAMBAH DATA --}}
+
+
+{{-- MODAL EDIT DATA --}}
+
+
+
+
@endsection
diff --git a/resources/views/admin/guru/show.blade.php b/resources/views/admin/guru/show.blade.php
new file mode 100644
index 0000000..7ae5629
--- /dev/null
+++ b/resources/views/admin/guru/show.blade.php
@@ -0,0 +1,48 @@
+@extends('admin.layouts.app')
+
+@section('title', 'Detail Guru')
+
+@section('content')
+
+
+
+
+
+
+
+
+ NIP
+ : {{ $guru->nip }}
+
+
+ Nama Lengkap
+ : {{ $guru->nama }}
+
+
+ Tanggal Dibuat
+ : {{ $guru->created_at->format('d F Y, H:i') }} WIB
+
+
+ Terakhir Update
+ : {{ $guru->updated_at->format('d F Y, H:i') }} WIB
+
+
+
+
+
+
+
+
+
+@endsection
\ No newline at end of file
diff --git a/resources/views/guru/create.blade.php b/resources/views/guru/create.blade.php
new file mode 100644
index 0000000..e69de29
diff --git a/resources/views/guru/edit.blade.php b/resources/views/guru/edit.blade.php
new file mode 100644
index 0000000..e69de29
diff --git a/resources/views/guru/index.blade.php b/resources/views/guru/index.blade.php
new file mode 100644
index 0000000..e69de29
diff --git a/resources/views/guru/show.blade.php b/resources/views/guru/show.blade.php
new file mode 100644
index 0000000..e69de29
diff --git a/routes/web.php b/routes/web.php
index 07af958..e94835c 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -6,8 +6,9 @@
use App\Http\Controllers\Admin\LoginController;
use App\Http\Controllers\Admin\AdminController;
+use App\Http\Controllers\Admin\GuruController;
-use App\Http\Controllers\GuruController;
+// use App\Http\Controllers\GuruController;
use App\Http\Controllers\SiswaController;
use App\Http\Controllers\KelasController;
use App\Http\Controllers\MapelController;