diff --git a/app/Http/Controllers/Admin/AdminDashboardController.php b/app/Http/Controllers/Admin/AdminDashboardController.php new file mode 100644 index 0000000..73df6d7 --- /dev/null +++ b/app/Http/Controllers/Admin/AdminDashboardController.php @@ -0,0 +1,80 @@ +whereNotNull('penyakit_final') + ->groupBy('penyakit_final') + ->orderBy('total', 'desc') + ->limit(5) + ->get(); + + // Join dengan MasterPenyakit untuk ambil nama lengkap + $chartPenyakit = [ + 'labels' => $penyakitTerbanyak->map(function($item) { + // Cari nama penyakit berdasarkan kode + $penyakit = MasterPenyakit::where('kode_penyakit', $item->penyakit_final)->first(); + return $penyakit ? $penyakit->nama_penyakit : $item->penyakit_final; + })->toArray(), + 'data' => $penyakitTerbanyak->pluck('total')->toArray(), + ]; + + // Chart: Trend Diagnosa Per Bulan (6 bulan terakhir) + $sixMonthsAgo = Carbon::now()->subMonths(6); + + $diagnosaTrend = RiwayatDiagnosis::where('created_at', '>=', $sixMonthsAgo) + ->select( + DB::raw('DATE_FORMAT(created_at, "%Y-%m") as bulan'), + DB::raw('count(*) as total') + ) + ->groupBy('bulan') + ->orderBy('bulan') + ->get(); + + // Generate all months for the last 6 months + $months = collect(); + for ($i = 5; $i >= 0; $i--) { + $months->push(Carbon::now()->subMonths($i)); + } + + $chartDiagnosa = [ + 'labels' => $months->map(function($month) { + return $month->translatedFormat('M Y'); + })->toArray(), + 'data' => $months->map(function($month) use ($diagnosaTrend) { + $bulan = $month->format('Y-m'); + $found = $diagnosaTrend->firstWhere('bulan', $bulan); + return $found ? $found->total : 0; + })->toArray(), + ]; + + return view('admin.dashboard', compact( + 'totalGejala', + 'totalPenyakit', + 'totalDiagnosa', + 'totalArtikel', + 'chartPenyakit', + 'chartDiagnosa' + )); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Admin/ArtikelController.php b/app/Http/Controllers/Admin/ArtikelController.php new file mode 100644 index 0000000..4dd8fe5 --- /dev/null +++ b/app/Http/Controllers/Admin/ArtikelController.php @@ -0,0 +1,146 @@ +get()->map(function($item) { + $item->kategori = 'Budidaya'; + return $item; + }); + + $hamaPenyakit = InformasiHamaPenyakit::latest()->get()->map(function($item) { + $item->kategori = 'Hama & Penyakit'; + return $item; + }); + + // Gabungkan dan paginate manual + $artikels = $budidaya->merge($hamaPenyakit)->sortByDesc('created_at'); + + // Convert ke paginator + $page = request()->get('page', 1); + $perPage = 10; + $artikels = new \Illuminate\Pagination\LengthAwarePaginator( + $artikels->forPage($page, $perPage), + $artikels->count(), + $perPage, + $page, + ['path' => request()->url(), 'query' => request()->query()] + ); + + return view('admin.artikel.index', compact('artikels')); + } + + /** + * Show the form for creating a new artikel. + */ + public function create() + { + return view('admin.artikel.create'); + } + + /** + * Store a newly created artikel. + */ + public function store(Request $request) + { + $validated = $request->validate([ + 'kategori' => ['required', 'in:budidaya,hama_penyakit'], + 'judul' => ['required', 'string', 'max:255'], + 'konten' => ['required', 'string'], + 'gambar' => ['nullable', 'image', 'max:2048'], + ]); + + // Upload gambar jika ada + if ($request->hasFile('gambar')) { + $validated['gambar'] = $request->file('gambar')->store('artikel', 'public'); + } + + $validated['created_by'] = auth()->id(); + + // Simpan ke tabel yang sesuai + if ($validated['kategori'] === 'budidaya') { + InformasiBudidaya::create($validated); + } else { + InformasiHamaPenyakit::create($validated); + } + + return redirect()->route('admin.artikel.index') + ->with('success', 'Artikel berhasil ditambahkan!'); + } + + /** + * Show the form for editing artikel. + */ + public function edit($id) + { + // Cari di kedua tabel + $artikel = InformasiBudidaya::find($id); + $kategori = 'budidaya'; + + if (!$artikel) { + $artikel = InformasiHamaPenyakit::findOrFail($id); + $kategori = 'hama_penyakit'; + } + + return view('admin.artikel.edit', compact('artikel', 'kategori')); + } + + /** + * Update the specified artikel. + */ + public function update(Request $request, $id) + { + $validated = $request->validate([ + 'kategori' => ['required', 'in:budidaya,hama_penyakit'], + 'judul' => ['required', 'string', 'max:255'], + 'konten' => ['required', 'string'], + 'gambar' => ['nullable', 'image', 'max:2048'], + ]); + + // Upload gambar baru jika ada + if ($request->hasFile('gambar')) { + $validated['gambar'] = $request->file('gambar')->store('artikel', 'public'); + } + + // Update di tabel yang sesuai + if ($validated['kategori'] === 'budidaya') { + $artikel = InformasiBudidaya::findOrFail($id); + } else { + $artikel = InformasiHamaPenyakit::findOrFail($id); + } + + $artikel->update($validated); + + return redirect()->route('admin.artikel.index') + ->with('success', 'Artikel berhasil diupdate!'); + } + + /** + * Remove the specified artikel. + */ + public function destroy($id) + { + // Coba hapus dari kedua tabel + $deleted = InformasiBudidaya::where('id', $id)->delete(); + + if (!$deleted) { + InformasiHamaPenyakit::where('id', $id)->delete(); + } + + return redirect()->route('admin.artikel.index') + ->with('success', 'Artikel berhasil dihapus!'); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Admin/GejalaController.php b/app/Http/Controllers/Admin/GejalaController.php new file mode 100644 index 0000000..956d8ba --- /dev/null +++ b/app/Http/Controllers/Admin/GejalaController.php @@ -0,0 +1,92 @@ +paginate(10); + return view('admin.gejala.index', compact('gejalas')); + } + + /** + * Show the form for creating a new gejala. + */ + public function create() + { + return view('admin.gejala.create'); + } + + /** + * Store a newly created gejala. + */ + public function store(Request $request) + { + $validated = $request->validate([ + 'kode_gejala' => ['required', 'string', 'max:10', 'unique:gejala,kode_gejala'], + 'nama_gejala' => ['required', 'string', 'max:255'], + ], [ + 'kode_gejala.unique' => 'Kode gejala sudah digunakan', + 'kode_gejala.required' => 'Kode gejala wajib diisi', + 'nama_gejala.required' => 'Nama gejala wajib diisi', + ]); + + MasterGejala::create($validated); + + return redirect()->route('admin.gejala.index') + ->with('success', 'Gejala berhasil ditambahkan!'); + } + + /** + * Display the specified gejala. + */ + public function show(MasterGejala $gejala) + { + return view('admin.gejala.show', compact('gejala')); + } + + /** + * Show the form for editing gejala. + */ + public function edit(MasterGejala $gejala) + { + return view('admin.gejala.edit', compact('gejala')); + } + + /** + * Update the specified gejala. + */ + public function update(Request $request, MasterGejala $gejala) + { + $validated = $request->validate([ + 'kode_gejala' => ['required', 'string', 'max:10', 'unique:gejala,kode_gejala,' . $gejala->id], + 'nama_gejala' => ['required', 'string', 'max:255'], + ], [ + 'kode_gejala.unique' => 'Kode gejala sudah digunakan', + ]); + + $gejala->update($validated); + + return redirect()->route('admin.gejala.index') + ->with('success', 'Gejala berhasil diupdate!'); + } + + /** + * Remove the specified gejala. + */ + public function destroy(MasterGejala $gejala) + { + $gejala->delete(); + + return redirect()->route('admin.gejala.index') + ->with('success', 'Gejala berhasil dihapus!'); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Admin/PenyakitController.php b/app/Http/Controllers/Admin/PenyakitController.php new file mode 100644 index 0000000..6768a48 --- /dev/null +++ b/app/Http/Controllers/Admin/PenyakitController.php @@ -0,0 +1,156 @@ +paginate(10); + return view('admin.penyakit.index', compact('penyakits')); + } + + /** + * Show the form for creating a new penyakit. + */ + public function create() + { + return view('admin.penyakit.create'); + } + + /** + * Store a newly created penyakit. + */ + public function store(Request $request) + { + $validated = $request->validate([ + 'id_penyakit' => ['required', 'string', 'max:10', 'unique:master_penyakit,id_penyakit'], + 'nama_penyakit' => ['required', 'string', 'max:255'], + 'nama_latin' => ['nullable', 'string', 'max:255'], + 'kategori' => ['required', 'in:Hama,Penyakit'], + 'deskripsi_singkat' => ['nullable', 'string'], + 'deskripsi_lengkap' => ['nullable', 'string'], + 'pengendalian_pencegahan' => ['nullable', 'string'], + 'pengendalian_kimia' => ['nullable', 'string'], + 'pengendalian_organik' => ['nullable', 'string'], + 'pengendalian_budidaya' => ['nullable', 'string'], + 'tingkat_bahaya' => ['nullable', 'in:Rendah,Sedang,Tinggi,Sangat Tinggi'], + 'gambar' => ['nullable', 'image', 'mimes:jpg,jpeg,png,webp', 'max:2048'], + ], [ + 'id_penyakit.required' => 'Kode penyakit wajib diisi', + 'id_penyakit.unique' => 'Kode penyakit sudah digunakan', + 'nama_penyakit.required' => 'Nama penyakit wajib diisi', + 'kategori.required' => 'Kategori wajib dipilih', + 'kategori.in' => 'Kategori harus Hama atau Penyakit', + 'tingkat_bahaya.in' => 'Tingkat bahaya tidak valid', + 'gambar.image' => 'File harus berupa gambar', + 'gambar.mimes' => 'Format gambar harus JPG, JPEG, PNG, atau WebP', + 'gambar.max' => 'Ukuran gambar maksimal 2MB', + ]); + + // Handle file upload + if ($request->hasFile('gambar')) { + $file = $request->file('gambar'); + $filename = time() . '_' . $file->getClientOriginalName(); + $file->move(public_path('uploads/penyakit'), $filename); + $validated['gambar_url'] = '/uploads/penyakit/' . $filename; + } + + MasterPenyakit::create($validated); + + return redirect()->route('admin.penyakit.index') + ->with('success', 'Penyakit berhasil ditambahkan!'); + } + + /** + * Display the specified penyakit. + */ + public function show(MasterPenyakit $penyakit) + { + return view('admin.penyakit.show', compact('penyakit')); + } + + /** + * Show the form for editing penyakit. + */ + public function edit(MasterPenyakit $penyakit) + { + return view('admin.penyakit.edit', compact('penyakit')); + } + + /** + * Update the specified penyakit. + */ + public function update(Request $request, MasterPenyakit $penyakit) + { + $validated = $request->validate([ + 'nama_penyakit' => ['required', 'string', 'max:255'], + 'nama_latin' => ['nullable', 'string', 'max:255'], + 'kategori' => ['required', 'in:Hama,Penyakit'], + 'deskripsi_singkat' => ['nullable', 'string'], + 'deskripsi_lengkap' => ['nullable', 'string'], + 'pengendalian_pencegahan' => ['nullable', 'string'], + 'pengendalian_kimia' => ['nullable', 'string'], + 'pengendalian_organik' => ['nullable', 'string'], + 'pengendalian_budidaya' => ['nullable', 'string'], + 'tingkat_bahaya' => ['nullable', 'in:Rendah,Sedang,Tinggi,Sangat Tinggi'], + 'gambar' => ['nullable', 'image', 'mimes:jpg,jpeg,png,webp', 'max:2048'], + ], [ + 'nama_penyakit.required' => 'Nama penyakit wajib diisi', + 'kategori.required' => 'Kategori wajib dipilih', + 'kategori.in' => 'Kategori harus Hama atau Penyakit', + 'tingkat_bahaya.in' => 'Tingkat bahaya tidak valid', + 'gambar.image' => 'File harus berupa gambar', + 'gambar.mimes' => 'Format gambar harus JPG, JPEG, PNG, atau WebP', + 'gambar.max' => 'Ukuran gambar maksimal 2MB', + ]); + + // Handle file upload + if ($request->hasFile('gambar')) { + // Delete old image if exists + if ($penyakit->gambar_url && file_exists(public_path($penyakit->gambar_url))) { + unlink(public_path($penyakit->gambar_url)); + } + + // Store new image + $file = $request->file('gambar'); + $filename = time() . '_' . $file->getClientOriginalName(); + $file->move(public_path('uploads/penyakit'), $filename); + $validated['gambar_url'] = '/uploads/penyakit/' . $filename; + } + + $penyakit->update($validated); + + return redirect()->route('admin.penyakit.index') + ->with('success', 'Data penyakit berhasil diupdate!'); + } + + /** + * Check if kode penyakit already exists (AJAX) + */ + public function checkKode(Request $request) + { + $kode = $request->query('kode'); + $exists = MasterPenyakit::where('id_penyakit', $kode)->exists(); + + return response()->json(['exists' => $exists]); + } + + /** + * Remove the specified penyakit. + */ + public function destroy(MasterPenyakit $penyakit) + { + $penyakit->delete(); + + return redirect()->route('admin.penyakit.index') + ->with('success', 'Penyakit berhasil dihapus!'); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/SuperAdmin/UserManagementController.php b/app/Http/Controllers/SuperAdmin/UserManagementController.php new file mode 100644 index 0000000..f4a3afd --- /dev/null +++ b/app/Http/Controllers/SuperAdmin/UserManagementController.php @@ -0,0 +1,104 @@ +paginate(10); + return view('super-admin.users.index', compact('users')); + } + + /** + * Show the form for creating a new user. + */ + public function create() + { + return view('super-admin.users.create'); + } + + /** + * Store a newly created user. + */ + public function store(Request $request) + { + $validated = $request->validate([ + 'username' => ['required', 'string', 'max:50', 'alpha_dash', 'unique:users,username'], + 'nama' => ['required', 'string', 'max:100'], + 'email' => ['required', 'string', 'email', 'max:255', 'unique:users,email'], + 'password' => ['required', 'string', 'min:8', 'confirmed'], + 'no_hp' => ['nullable', 'string', 'max:15'], + 'role' => ['required', 'in:super_admin,admin,user'], + ]); + + $validated['password'] = Hash::make($validated['password']); + $validated['email_verified_at'] = now(); + + User::create($validated); + + return redirect()->route('super-admin.users.index') + ->with('success', 'User berhasil ditambahkan!'); + } + + /** + * Show the form for editing user. + */ + public function edit(User $user) + { + return view('super-admin.users.edit', compact('user')); + } + + /** + * Update the specified user. + */ + public function update(Request $request, User $user) + { + $validated = $request->validate([ + 'username' => ['required', 'string', 'max:50', 'alpha_dash', Rule::unique('users')->ignore($user->id)], + 'nama' => ['required', 'string', 'max:100'], + 'email' => ['required', 'string', 'email', 'max:255', Rule::unique('users')->ignore($user->id)], + 'no_hp' => ['nullable', 'string', 'max:15'], + 'role' => ['required', 'in:super_admin,admin,user'], + ]); + + // Update password hanya jika diisi + if ($request->filled('password')) { + $request->validate([ + 'password' => ['string', 'min:8', 'confirmed'], + ]); + $validated['password'] = Hash::make($request->password); + } + + $user->update($validated); + + return redirect()->route('super-admin.users.index') + ->with('success', 'User berhasil diupdate!'); + } + + /** + * Remove the specified user. + */ + public function destroy(User $user) + { + // Cegah super admin menghapus dirinya sendiri + if ($user->id === auth()->id()) { + return redirect()->route('super-admin.users.index') + ->with('error', 'Anda tidak dapat menghapus akun sendiri!'); + } + + $user->delete(); + + return redirect()->route('super-admin.users.index') + ->with('success', 'User berhasil dihapus!'); + } +} \ No newline at end of file diff --git a/app/Http/Middleware/IsAdmin.php b/app/Http/Middleware/IsAdmin.php new file mode 100644 index 0000000..6b06e61 --- /dev/null +++ b/app/Http/Middleware/IsAdmin.php @@ -0,0 +1,30 @@ +check()) { + return redirect()->route('login')->with('error', 'Silakan login terlebih dahulu'); + } + + // Cek apakah user punya akses admin (admin ATAU super_admin) + if (!auth()->user()->hasAdminAccess()) { + abort(403, 'Akses ditolak. Hanya Admin yang diizinkan.'); + } + + return $next($request); + } +} \ No newline at end of file diff --git a/app/Http/Middleware/IsSuperAdmin.php b/app/Http/Middleware/IsSuperAdmin.php new file mode 100644 index 0000000..93b7711 --- /dev/null +++ b/app/Http/Middleware/IsSuperAdmin.php @@ -0,0 +1,23 @@ +check()) { + return redirect()->route('login')->with('error', 'Silakan login terlebih dahulu'); + } + + if (!auth()->user()->isSuperAdmin()) { + abort(403, 'Akses ditolak. Hanya Super Admin yang diizinkan.'); + } + + return $next($request); + } +} \ No newline at end of file diff --git a/app/Http/Middleware/Redirectifauthenticated.php b/app/Http/Middleware/Redirectifauthenticated.php new file mode 100644 index 0000000..0c38865 --- /dev/null +++ b/app/Http/Middleware/Redirectifauthenticated.php @@ -0,0 +1,39 @@ +check()) { + // Redirect berdasarkan role + $user = Auth::user(); + + if ($user->role === 'super_admin') { + return redirect('/super-admin/dashboard'); + } elseif ($user->role === 'admin') { + return redirect('/admin/dashboard'); + } else { + return redirect(RouteServiceProvider::HOME); + } + } + } + + return $next($request); + } +} \ No newline at end of file diff --git a/app/Models/User.php b/app/Models/User.php index 84cd219..4e4357f 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -2,77 +2,87 @@ namespace App\Models; -// use Illuminate\Contracts\Auth\MustVerifyEmail; -use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; class User extends Authenticatable { - use HasFactory, Notifiable; + use Notifiable; /** - * Kolom yang bisa diisi mass assignment + * The attributes that are mass assignable. + * + * @var array */ protected $fillable = [ 'username', 'nama', 'email', + 'password', 'no_hp', 'role', - 'password', ]; /** - * Kolom yang di-hidden saat serialization (JSON) + * The attributes that should be hidden for serialization. + * + * @var array */ protected $hidden = [ 'password', + 'remember_token', ]; /** - * Casting tipe data + * Get the attributes that should be cast. + * + * @return array */ - protected $casts = [ - 'created_at' => 'datetime', - 'updated_at' => 'datetime', - 'password' => 'hashed', // Laravel 10+ auto hash - ]; + protected function casts(): array + { + return [ + 'email_verified_at' => 'datetime', + 'password' => 'hashed', + ]; + } // ============================================ // RELATIONSHIPS // ============================================ - /** - * User punya banyak riwayat diagnosis - */ public function riwayatDiagnosis() { return $this->hasMany(RiwayatDiagnosis::class, 'user_id'); } - /** - * Admin upload banyak artikel budidaya - */ public function artikelBudidaya() { return $this->hasMany(InformasiBudidaya::class, 'created_by'); } - /** - * Admin upload banyak artikel hama/penyakit - */ public function artikelHamaPenyakit() { return $this->hasMany(InformasiHamaPenyakit::class, 'created_by'); } // ============================================ - // HELPER METHODS + // ROLE CHECKER HELPER METHODS // ============================================ /** - * Cek apakah user adalah admin + * Cek apakah user adalah Super Admin + * + * @return bool + */ + public function isSuperAdmin() + { + return $this->role === 'super_admin'; + } + + /** + * Cek apakah user adalah Admin (TETAP SEPERTI SEBELUMNYA) + * + * @return bool */ public function isAdmin() { @@ -80,7 +90,9 @@ public function isAdmin() } /** - * Cek apakah user biasa + * Cek apakah user biasa (TETAP SEPERTI SEBELUMNYA) + * + * @return bool */ public function isUser() { @@ -88,11 +100,53 @@ public function isUser() } /** - * Get display name - * (Karena Laravel default cari 'name', kita redirect ke 'nama') + * Cek apakah user punya akses admin (Super Admin ATAU Admin) + * Helper baru untuk middleware yang butuh cek "apakah user ini admin atau super admin" + * + * @return bool */ - public function getNameAttribute() + public function hasAdminAccess() { - return $this->nama; + return in_array($this->role, ['super_admin', 'admin']); + } + + /** + * Cek apakah user punya akses super admin (alias dari isSuperAdmin) + * + * @return bool + */ + public function hasSuperAdminAccess() + { + return $this->isSuperAdmin(); + } + + /** + * Get role display name (untuk tampilan) + * + * @return string + */ + public function getRoleDisplayName() + { + return match($this->role) { + 'super_admin' => 'Super Administrator', + 'admin' => 'Administrator', + 'user' => 'User', + default => 'Unknown', + }; + } + + /** + * Get role badge color (untuk UI) + * + * @return string + */ + public function getRoleBadgeColor() + { + return match($this->role) { + 'super_admin' => 'red', + 'admin' => 'blue', + 'user' => 'gray', + default => 'gray', + }; } } \ No newline at end of file diff --git a/bootstrap/app.php b/bootstrap/app.php index c183276..bb704ca 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -11,7 +11,10 @@ health: '/up', ) ->withMiddleware(function (Middleware $middleware): void { - // + $middleware->alias([ + 'admin' => \App\Http\Middleware\IsAdmin::class, + 'super_admin' => \App\Http\Middleware\IsSuperAdmin::class, + ]); }) ->withExceptions(function (Exceptions $exceptions): void { // diff --git a/database/migrations/2026_02_14_092201_update_role_enum_in_users_table.php b/database/migrations/2026_02_14_092201_update_role_enum_in_users_table.php new file mode 100644 index 0000000..9bc8462 --- /dev/null +++ b/database/migrations/2026_02_14_092201_update_role_enum_in_users_table.php @@ -0,0 +1,21 @@ +dropForeign('riwayat_diagnosis_penyakit_final_foreign'); + }); + + // Step 2: Set id_penyakit jadi AUTO_INCREMENT + DB::statement('ALTER TABLE master_penyakit MODIFY id_penyakit BIGINT UNSIGNED NOT NULL AUTO_INCREMENT'); + + // Step 3: Ubah penyakit_final dari VARCHAR(10) jadi BIGINT UNSIGNED + DB::statement('ALTER TABLE riwayat_diagnosis MODIFY penyakit_final BIGINT UNSIGNED NULL'); + + // Step 4: Buat foreign key lagi dengan tipe data yang benar + Schema::table('riwayat_diagnosis', function (Blueprint $table) { + $table->foreign('penyakit_final') + ->references('id_penyakit') + ->on('master_penyakit') + ->onDelete('set null'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + // Rollback: Drop foreign key + Schema::table('riwayat_diagnosis', function (Blueprint $table) { + $table->dropForeign(['penyakit_final']); + }); + + // Kembalikan penyakit_final jadi VARCHAR(10) + DB::statement('ALTER TABLE riwayat_diagnosis MODIFY penyakit_final VARCHAR(10) NULL'); + + // Hapus AUTO_INCREMENT dari id_penyakit + DB::statement('ALTER TABLE master_penyakit MODIFY id_penyakit BIGINT UNSIGNED NOT NULL'); + + // Buat foreign key lagi ke kode_penyakit (struktur lama) + // Note: Ini opsional, sesuaikan dengan struktur database awal kamu + } +}; \ No newline at end of file diff --git a/public/uploads/penyakit/1771148117_WhatsApp Image 2025-12-19 at 01.04.50 (1).jpeg b/public/uploads/penyakit/1771148117_WhatsApp Image 2025-12-19 at 01.04.50 (1).jpeg new file mode 100644 index 0000000..2b57126 Binary files /dev/null and b/public/uploads/penyakit/1771148117_WhatsApp Image 2025-12-19 at 01.04.50 (1).jpeg differ diff --git a/public/uploads/penyakit/1771150767_WhatsApp Image 2025-12-19 at 01.04.50 (1).jpeg b/public/uploads/penyakit/1771150767_WhatsApp Image 2025-12-19 at 01.04.50 (1).jpeg new file mode 100644 index 0000000..2b57126 Binary files /dev/null and b/public/uploads/penyakit/1771150767_WhatsApp Image 2025-12-19 at 01.04.50 (1).jpeg differ diff --git a/public/uploads/penyakit/1771150868_WhatsApp Image 2025-12-19 at 01.04.50 (1).jpeg b/public/uploads/penyakit/1771150868_WhatsApp Image 2025-12-19 at 01.04.50 (1).jpeg new file mode 100644 index 0000000..2b57126 Binary files /dev/null and b/public/uploads/penyakit/1771150868_WhatsApp Image 2025-12-19 at 01.04.50 (1).jpeg differ diff --git a/public/uploads/penyakit/1771910821_penggerek buah kopi.webp b/public/uploads/penyakit/1771910821_penggerek buah kopi.webp new file mode 100644 index 0000000..ad5ce46 Binary files /dev/null and b/public/uploads/penyakit/1771910821_penggerek buah kopi.webp differ diff --git a/public/uploads/penyakit/1771911161_Penggerek Batang Merah (Zeuzera coffear).png b/public/uploads/penyakit/1771911161_Penggerek Batang Merah (Zeuzera coffear).png new file mode 100644 index 0000000..046e643 Binary files /dev/null and b/public/uploads/penyakit/1771911161_Penggerek Batang Merah (Zeuzera coffear).png differ diff --git a/public/uploads/penyakit/1771911574_hama penggerek cabang dan ranting.webp b/public/uploads/penyakit/1771911574_hama penggerek cabang dan ranting.webp new file mode 100644 index 0000000..a6600d5 Binary files /dev/null and b/public/uploads/penyakit/1771911574_hama penggerek cabang dan ranting.webp differ diff --git a/public/uploads/penyakit/1771912016_kutu hijau.jpg b/public/uploads/penyakit/1771912016_kutu hijau.jpg new file mode 100644 index 0000000..1d3253b Binary files /dev/null and b/public/uploads/penyakit/1771912016_kutu hijau.jpg differ diff --git a/public/uploads/penyakit/1771913967_wereng.jpg b/public/uploads/penyakit/1771913967_wereng.jpg new file mode 100644 index 0000000..51282a7 Binary files /dev/null and b/public/uploads/penyakit/1771913967_wereng.jpg differ diff --git a/public/uploads/penyakit/1771914249_Hemileia vastatrix.webp b/public/uploads/penyakit/1771914249_Hemileia vastatrix.webp new file mode 100644 index 0000000..4d1577c Binary files /dev/null and b/public/uploads/penyakit/1771914249_Hemileia vastatrix.webp differ diff --git a/public/uploads/penyakit/1771914520_bercak daun.webp b/public/uploads/penyakit/1771914520_bercak daun.webp new file mode 100644 index 0000000..e99e754 Binary files /dev/null and b/public/uploads/penyakit/1771914520_bercak daun.webp differ diff --git a/public/uploads/penyakit/1771914847_jamur upas.webp b/public/uploads/penyakit/1771914847_jamur upas.webp new file mode 100644 index 0000000..1a1b47f Binary files /dev/null and b/public/uploads/penyakit/1771914847_jamur upas.webp differ diff --git a/public/uploads/penyakit/1771915699_kanker belaah.jpg b/public/uploads/penyakit/1771915699_kanker belaah.jpg new file mode 100644 index 0000000..ba23f25 Binary files /dev/null and b/public/uploads/penyakit/1771915699_kanker belaah.jpg differ diff --git a/public/uploads/penyakit/1771918175_jamur akar putih.jpg b/public/uploads/penyakit/1771918175_jamur akar putih.jpg new file mode 100644 index 0000000..e32943d Binary files /dev/null and b/public/uploads/penyakit/1771918175_jamur akar putih.jpg differ diff --git a/public/uploads/penyakit/1771933104_Phellinus noxius.jpg b/public/uploads/penyakit/1771933104_Phellinus noxius.jpg new file mode 100644 index 0000000..6a9bb46 Binary files /dev/null and b/public/uploads/penyakit/1771933104_Phellinus noxius.jpg differ diff --git a/public/uploads/penyakit/1771934104_Roselina bunodes.jpg b/public/uploads/penyakit/1771934104_Roselina bunodes.jpg new file mode 100644 index 0000000..0bd02e2 Binary files /dev/null and b/public/uploads/penyakit/1771934104_Roselina bunodes.jpg differ diff --git a/public/uploads/penyakit/1771934692_mati pucuk.jpg b/public/uploads/penyakit/1771934692_mati pucuk.jpg new file mode 100644 index 0000000..dbd1d53 Binary files /dev/null and b/public/uploads/penyakit/1771934692_mati pucuk.jpg differ diff --git a/public/uploads/penyakit/1771935968_rebah batang.jpg b/public/uploads/penyakit/1771935968_rebah batang.jpg new file mode 100644 index 0000000..e425038 Binary files /dev/null and b/public/uploads/penyakit/1771935968_rebah batang.jpg differ diff --git a/public/uploads/penyakit/1771944022_luka akar nematoda.jpeg b/public/uploads/penyakit/1771944022_luka akar nematoda.jpeg new file mode 100644 index 0000000..0cc2ea6 Binary files /dev/null and b/public/uploads/penyakit/1771944022_luka akar nematoda.jpeg differ diff --git a/public/uploads/penyakit/1771945042_radopholus similis.jpg b/public/uploads/penyakit/1771945042_radopholus similis.jpg new file mode 100644 index 0000000..bec5929 Binary files /dev/null and b/public/uploads/penyakit/1771945042_radopholus similis.jpg differ diff --git a/public/uploads/penyakit/1771945471_meloidogye.jpg b/public/uploads/penyakit/1771945471_meloidogye.jpg new file mode 100644 index 0000000..66aab2c Binary files /dev/null and b/public/uploads/penyakit/1771945471_meloidogye.jpg differ diff --git a/resources/views/admin/artikel/index.blade.php b/resources/views/admin/artikel/index.blade.php new file mode 100644 index 0000000..9abbd9e --- /dev/null +++ b/resources/views/admin/artikel/index.blade.php @@ -0,0 +1,101 @@ +@extends('layouts.admin-app') + +@section('page-title', '📰 Manajemen Artikel') +@section('page-subtitle', 'Kelola artikel edukasi') + +@section('content') + @if (session('success')) +
+ + + + {{ session('success') }} +
+ @endif + +
+
+
+
+
+ + + +
+

Daftar Artikel Edukasi

+
+ + + + + Tambah Artikel + +
+ +
+ + + + + + + + + + + + + @forelse ($artikels as $index => $artikel) + + + + + + + + + @empty + + + + @endforelse + +
NoJudulKategoriPenulisTanggalAksi
{{ $artikels->firstItem() + $index }} +
{{ $artikel->judul }}
+
+ + {{ $artikel->kategori }} + + {{ $artikel->penulis ?? 'Admin' }}{{ $artikel->created_at->format('d M Y') }} +
+ + + + + Edit + +
+ @csrf + @method('DELETE') + +
+
+
+
+ + + +

Belum ada artikel

+
+
+
+ +
{{ $artikels->links() }}
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/admin/dashboard.blade.php b/resources/views/admin/dashboard.blade.php new file mode 100644 index 0000000..650b612 --- /dev/null +++ b/resources/views/admin/dashboard.blade.php @@ -0,0 +1,148 @@ +@extends('layouts.admin-app') + +@section('page-title', '📊 Dashboard') +@section('page-subtitle', 'Overview statistik sistem pakar') + +@section('content') + +
+
+
+
+

Selamat Datang Kembali! 👋

+

{{ Auth::user()->nama }}

+

{{ now()->translatedFormat('l, d F Y') }}

+
+
+ + +
+ +
+
+
+

Total Gejala

+

{{ $totalGejala }}

+
+
+ + + +
+
+
+ + +
+
+
+

Total Penyakit

+

{{ $totalPenyakit }}

+
+
+ + + +
+
+
+ + +
+
+
+

Total Diagnosa

+

{{ $totalDiagnosa }}

+
+
+ + + +
+
+
+ + +
+
+
+

Total Artikel

+

{{ $totalArtikel }}

+
+
+ + + +
+
+
+
+ + +
+ +
+

Penyakit Paling Sering Didiagnosa

+
+ +
+
+ + +
+

Trend Diagnosa (6 Bulan Terakhir)

+
+ +
+
+
+ + + + +@endsection \ No newline at end of file diff --git a/resources/views/admin/gejala/index.blade.php b/resources/views/admin/gejala/index.blade.php new file mode 100644 index 0000000..a2ccb74 --- /dev/null +++ b/resources/views/admin/gejala/index.blade.php @@ -0,0 +1,97 @@ +@extends('layouts.admin-app') + +@section('page-title', '✅ Manajemen Gejala') +@section('page-subtitle', 'Kelola data gejala penyakit') + +@section('content') + @if (session('success')) +
+ + + + {{ session('success') }} +
+ @endif + +
+
+
+
+
+ + + +
+

Daftar Gejala Penyakit

+
+ + + + + Tambah Gejala + +
+ +
+ + + + + + + + + + + @forelse ($gejalas as $index => $gejala) + + + + + + + @empty + + + + @endforelse + +
NoKodeNama GejalaAksi
{{ $gejalas->firstItem() + $index }} + + {{ $gejala->kode_gejala }} + + +
{{ $gejala->nama_gejala }}
+
+
+ + + + + Edit + +
+ @csrf + @method('DELETE') + +
+
+
+
+ + + +

Belum ada data gejala

+
+
+
+ +
{{ $gejalas->links() }}
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/admin/penyakit/create.blade.php b/resources/views/admin/penyakit/create.blade.php new file mode 100644 index 0000000..bb68057 --- /dev/null +++ b/resources/views/admin/penyakit/create.blade.php @@ -0,0 +1,274 @@ +@extends('layouts.admin-app') + +@section('page-title', '➕ Tambah Penyakit') +@section('page-subtitle', 'Tambah data penyakit tanaman kopi baru') + +@section('content') + @if ($errors->any()) +
+
+ + + +
+

Terdapat kesalahan:

+
    + @foreach ($errors->all() as $error) +
  • {{ $error }}
  • + @endforeach +
+
+
+
+ @endif + +
+ @csrf + +
+ +
+
+
+ + + +
+

Form Tambah Penyakit Baru

+
+
+ + +
+ + +
+ + +

Format: HP001 (Hama) atau P001 (Penyakit). Maksimal 10 karakter.

+ @error('id_penyakit') +

{{ $message }}

+ @enderror +
+ + +
+ + + @error('nama_penyakit') +

{{ $message }}

+ @enderror +
+ + +
+ + +
+ + +
+ + + @error('kategori') +

{{ $message }}

+ @enderror +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +

Format: JPG, PNG, WebP. Maksimal 2MB

+ + + +
+ +
+ + +
+ + Batal + + +
+
+
+ + + +@endsection \ No newline at end of file diff --git a/resources/views/admin/penyakit/edit.blade.php b/resources/views/admin/penyakit/edit.blade.php new file mode 100644 index 0000000..47d07f7 --- /dev/null +++ b/resources/views/admin/penyakit/edit.blade.php @@ -0,0 +1,280 @@ +@extends('layouts.admin-app') + +@section('page-title', '✏️ Edit Penyakit') +@section('page-subtitle', 'Edit data penyakit tanaman kopi') + +@section('content') + @if ($errors->any()) +
+
+ + + +
+

Terdapat kesalahan:

+
    + @foreach ($errors->all() as $error) +
  • {{ $error }}
  • + @endforeach +
+
+
+
+ @endif + +
+ @csrf + @method('PUT') + +
+ +
+
+
+ + + +
+

Form Edit Penyakit

+
+
+ + +
+ + +
+ + +

Kode penyakit tidak dapat diubah setelah dibuat.

+
+ + +
+ + + @error('nama_penyakit') +

{{ $message }}

+ @enderror +
+ + +
+ + +
+ + +
+ + + @error('kategori') +

{{ $message }}

+ @enderror +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +

Format: JPG, PNG, WebP. Maksimal 2MB

+ + + + + + @if($penyakit->gambar_url) +
+

Gambar saat ini:

+ Current +

Upload gambar baru untuk mengganti

+
+ @endif +
+ +
+ + +
+ + Batal + + +
+
+
+ + + +@endsection \ No newline at end of file diff --git a/resources/views/admin/penyakit/index.blade.php b/resources/views/admin/penyakit/index.blade.php new file mode 100644 index 0000000..49bb130 --- /dev/null +++ b/resources/views/admin/penyakit/index.blade.php @@ -0,0 +1,266 @@ +@extends('layouts.admin-app') + +@section('page-title', '🦠 Manajemen Penyakit') +@section('page-subtitle', 'Kelola data penyakit tanaman kopi') + +@section('content') + @if (session('success')) + + @endif + + @if (session('error')) + + @endif + +
+ +
+
+
+
+ + + +
+

Daftar Penyakit & Hama Tanaman Kopi

+
+ + + + + Tambah Data + +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + @forelse ($penyakits as $index => $penyakit) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @empty + + + + @endforelse + +
NoKodeGambarNama PenyakitNama LatinKategoriDeskripsi SingkatDeskripsi LengkapPengendalian PencegahanPengendalian KimiaPengendalian OrganikPengendalian BudidayaTingkat BahayaAksi
+ {{ $penyakits->firstItem() + $index }} + + + {{ $penyakit->id_penyakit }} + + + @if($penyakit->gambar_url) + {{ $penyakit->nama_penyakit }} + @else +
+ + + +
+ @endif +
+
{{ $penyakit->nama_penyakit }}
+
+
{{ $penyakit->nama_latin ?? '-' }}
+
+ @if($penyakit->kategori === 'Penyakit') + + 🦠 Penyakit + + @elseif($penyakit->kategori === 'Hama') + + 🐛 Hama + + @else + + {{ $penyakit->kategori ?? '-' }} + + @endif + +
{{ Str::limit($penyakit->deskripsi_singkat ?? '-', 80) }}
+
+
{{ Str::limit($penyakit->deskripsi_lengkap ?? '-', 80) }}
+
+
{{ Str::limit($penyakit->pengendalian_pencegahan ?? '-', 60) }}
+
+
{{ Str::limit($penyakit->pengendalian_kimia ?? '-', 60) }}
+
+
{{ Str::limit($penyakit->pengendalian_organik ?? '-', 60) }}
+
+
{{ Str::limit($penyakit->pengendalian_budidaya ?? '-', 60) }}
+
+ @if($penyakit->tingkat_bahaya === 'Sangat Tinggi') + {{ $penyakit->tingkat_bahaya }} + @elseif($penyakit->tingkat_bahaya === 'Tinggi') + {{ $penyakit->tingkat_bahaya }} + @elseif($penyakit->tingkat_bahaya === 'Sedang') + {{ $penyakit->tingkat_bahaya }} + @elseif($penyakit->tingkat_bahaya === 'Rendah') + {{ $penyakit->tingkat_bahaya }} + @else + {{ $penyakit->tingkat_bahaya ?? '-' }} + @endif + +
+ + + + + Edit + +
+ @csrf + @method('DELETE') + +
+
+
+
+ + + +

Belum ada data

+

Klik tombol "Tambah Data" untuk menambahkan penyakit atau hama

+
+
+
+ + +
+ {{ $penyakits->links() }} +
+
+ + + + + + +@endsection \ No newline at end of file diff --git a/resources/views/layouts/admin-app.blade.php b/resources/views/layouts/admin-app.blade.php new file mode 100644 index 0000000..5b1fc1d --- /dev/null +++ b/resources/views/layouts/admin-app.blade.php @@ -0,0 +1,281 @@ + + + + + + + + {{ config('app.name', 'Laravel') }} - Admin + + + + + + + @vite(['resources/css/app.css', 'resources/js/app.js']) + + + + + + + @stack('styles') + + +
+ + + + + + +
+ + @stack('scripts') + + \ No newline at end of file diff --git a/resources/views/profile/edit.blade.php b/resources/views/profile/edit.blade.php index e0e1d38..b4a82d4 100644 --- a/resources/views/profile/edit.blade.php +++ b/resources/views/profile/edit.blade.php @@ -1,29 +1,232 @@ - - -

- {{ __('Profile') }} -

-
+@extends('layouts.admin-app') -
-
-
-
- @include('profile.partials.update-profile-information-form') +@section('page-title', '👤 Profile Settings') +@section('page-subtitle', 'Kelola informasi profil Anda') + +@section('content') + +
+
+
+
+ + + +
+
+

Profile Information

+

Update your account's profile information and email address

-
-
- @include('profile.partials.update-password-form') + @if (session('status') === 'profile-updated') +
+ + + + Profile updated successfully!
-
+ @endif -
-
- @include('profile.partials.delete-user-form') +
+ @csrf + @method('patch') + + +
+ + + @error('username') +

{{ $message }}

+ @enderror
-
+ + +
+ + + @error('nama') +

{{ $message }}

+ @enderror +
+ + +
+ + + @error('email') +

{{ $message }}

+ @enderror + + @if ($user instanceof \Illuminate\Contracts\Auth\MustVerifyEmail && ! $user->hasVerifiedEmail()) +
+

+ Your email address is unverified. + +

+
+ @endif +
+ + +
+ + + @error('no_hp') +

{{ $message }}

+ @enderror +
+ + +
+ +
+
- + + +
+
+
+
+ + + +
+
+

Update Password

+

Ensure your account is using a long, random password to stay secure

+
+
+ + @if (session('status') === 'password-updated') +
+ + + + Password updated successfully! +
+ @endif + +
+ @csrf + @method('put') + + +
+ + + @error('current_password', 'updatePassword') +

{{ $message }}

+ @enderror +
+ + +
+ + + @error('password', 'updatePassword') +

{{ $message }}

+ @enderror +
+ + +
+ + + @error('password_confirmation', 'updatePassword') +

{{ $message }}

+ @enderror +
+ + +
+ +
+
+
+
+ + +
+
+
+
+ + + +
+
+

Delete Account

+

Once your account is deleted, all of its resources and data will be permanently deleted

+
+
+ + + + +
+
+@endsection \ No newline at end of file diff --git a/resources/views/super-admin/dashboard.blade.php b/resources/views/super-admin/dashboard.blade.php new file mode 100644 index 0000000..1f88c19 --- /dev/null +++ b/resources/views/super-admin/dashboard.blade.php @@ -0,0 +1,318 @@ + + +
+

+ ☕ {{ __('Super Admin Dashboard') }} +

+ + SUPER ADMIN + +
+
+ +
+
+ + +
+
+ +
+
+ +
+
+
+ + + +
+
+

Selamat Datang Kembali! 👋

+

{{ Auth::user()->nama }}

+
+
+

Sistem Pakar Diagnosa Tanaman Kopi

+
+
+ + + + {{ now()->translatedFormat('l, d F Y') }} +
+
+
+
+
+ + +
+ +
+
+
+
+

Total Users

+

{{ \App\Models\User::count() }}

+

Semua pengguna terdaftar

+
+
+ + + +
+
+
+
+ + + + Aktif +
+
+
+
+ + +
+
+
+
+

Super Admins

+

{{ \App\Models\User::where('role', 'super_admin')->count() }}

+

Administrator tertinggi

+
+
+ + + +
+
+
+
+ + + + Full Access +
+
+
+
+ + +
+
+
+
+

Admins

+

{{ \App\Models\User::where('role', 'admin')->count() }}

+

Administrator biasa

+
+
+ + + +
+
+
+
+ + + + Verified +
+
+
+
+ + +
+
+
+
+

Regular Users

+

{{ \App\Models\User::where('role', 'user')->count() }}

+

Pengguna biasa

+
+
+ + + +
+
+
+
+ + + + Community +
+
+
+
+
+ + + + + +
+
+
+
+
+ + + +
+

Recent Users

+
+ + View All + + + + +
+
+ + + + + + + + + + + + @forelse(\App\Models\User::latest()->take(5)->get() as $user) + + + + + + + + @empty + + + + @endforelse + +
UsernameNamaEmailRoleRegistered
+
+
+ {{ strtoupper(substr($user->username, 0, 1)) }} +
+
+
{{ $user->username }}
+
+
+
+
{{ $user->nama }}
+
+
{{ $user->email }}
+
+ @if($user->role === 'super_admin') + + ⭐ Super Admin + + @elseif($user->role === 'admin') + + 👤 Admin + + @else + + 👥 User + + @endif + +
+ + + + {{ $user->created_at->diffForHumans() }} +
+
+
+ + + +

Belum ada data user

+
+
+
+
+
+ +
+
+
\ No newline at end of file diff --git a/resources/views/super-admin/users/create.blade.php b/resources/views/super-admin/users/create.blade.php new file mode 100644 index 0000000..e4d6935 --- /dev/null +++ b/resources/views/super-admin/users/create.blade.php @@ -0,0 +1,79 @@ + + +

+ {{ __('Tambah User Baru') }} +

+
+ +
+
+
+
+ +
+ @csrf + + +
+ + + +
+ + +
+ + + +
+ + +
+ + + +
+ + +
+ + + +
+ + +
+ + +
+ + +
+ + + +
+ + +
+ + + +
+ +
+ {{ __('Simpan') }} + Batal +
+
+ +
+
+
+
+
\ No newline at end of file diff --git a/resources/views/super-admin/users/edit.blade.php b/resources/views/super-admin/users/edit.blade.php new file mode 100644 index 0000000..b96df8a --- /dev/null +++ b/resources/views/super-admin/users/edit.blade.php @@ -0,0 +1,79 @@ + + +

+ {{ __('Edit User') }} +

+
+ +
+
+
+
+ +
+ @csrf + @method('PUT') + + +
+ + + +
+ + +
+ + + +
+ + +
+ + + +
+ + +
+ + + +
+ + +
+ + +
+ + +
+ + + +
+ + +
+ + + +
+ +
+ {{ __('Update') }} + Batal +
+
+ +
+
+
+
+
diff --git a/resources/views/super-admin/users/index.blade.php b/resources/views/super-admin/users/index.blade.php new file mode 100644 index 0000000..c10cff1 --- /dev/null +++ b/resources/views/super-admin/users/index.blade.php @@ -0,0 +1,95 @@ + + +

+ {{ __('User Management') }} +

+
+ +
+
+
+
+ + @if (session('success')) +
+ {{ session('success') }} +
+ @endif + + @if (session('error')) +
+ {{ session('error') }} +
+ @endif + +
+

Daftar User

+ + + Tambah User + +
+ +
+ + + + + + + + + + + + + + @forelse ($users as $user) + + + + + + + + + + @empty + + + + @endforelse + +
IDUsernameNamaEmailNo HPRoleAksi
{{ $user->id }}{{ $user->username }}{{ $user->nama }}{{ $user->email }}{{ $user->no_hp ?? '-' }} + @if($user->role === 'super_admin') + Super Admin + @elseif($user->role === 'admin') + Admin + @else + User + @endif + +
+ Edit + + @if($user->id !== auth()->id()) +
+ @csrf + @method('DELETE') + +
+ @endif +
+
+ Belum ada data user. +
+
+ +
+ {{ $users->links() }} +
+ +
+
+
+
+
\ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 74bb7ca..72166e4 100644 --- a/routes/web.php +++ b/routes/web.php @@ -2,19 +2,65 @@ use App\Http\Controllers\ProfileController; use Illuminate\Support\Facades\Route; +use App\Http\Controllers\SuperAdmin\UserManagementController; +use App\Http\Controllers\Admin\AdminDashboardController; // ← TAMBAHKAN INI +use App\Http\Controllers\Admin\PenyakitController; // ← DAN INI +use App\Http\Controllers\Admin\GejalaController; // ← DAN INI +use App\Http\Controllers\Admin\ArtikelController; // ← DAN INI Route::get('/', function () { return view('welcome'); }); -Route::get('/dashboard', function () { - return view('dashboard'); -})->middleware(['auth', 'verified'])->name('dashboard'); +// Dashboard untuk user biasa +Route::middleware('auth')->group(function () { + Route::get('/dashboard', function () { + // Redirect berdasarkan role + if (auth()->user()->role === 'super_admin') { + return redirect()->route('super-admin.dashboard'); + } elseif (auth()->user()->role === 'admin') { + return redirect()->route('admin.dashboard'); + } + return view('dashboard'); + })->name('dashboard'); +}); +// Super Admin Routes +Route::middleware(['auth', App\Http\Middleware\IsSuperAdmin::class])->prefix('super-admin')->name('super-admin.')->group(function () { + Route::get('/dashboard', function () { + return view('super-admin.dashboard'); + })->name('dashboard'); + + Route::resource('users', App\Http\Controllers\SuperAdmin\UserManagementController::class); +}); + +// Admin Routes (kalau ada) +Route::middleware(['auth', App\Http\Middleware\IsAdmin::class]) + ->prefix('admin') + ->name('admin.') + ->group(function () { + // Dashboard Admin (dengan chart) + Route::get('/dashboard', [AdminDashboardController::class, 'index'])->name('dashboard'); + + // Penyakit Management + Route::resource('penyakit', PenyakitController::class); + + // Gejala Management + Route::resource('gejala', GejalaController::class); + + // Artikel Management + Route::resource('artikel', ArtikelController::class); + + // Bisa tambah route lain di sini: + // Route::resource('diagnosa', DiagnosaController::class); + // Route::resource('aturan', AturanController::class); + }); + +// Profile Routes Route::middleware('auth')->group(function () { Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit'); Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update'); Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy'); }); -require __DIR__.'/auth.php'; +require __DIR__.'/auth.php'; \ No newline at end of file