diff --git a/app/Http/Controllers/AdminDashboardController.php b/app/Http/Controllers/AdminDashboardController.php index 716af41..b2c3c10 100644 --- a/app/Http/Controllers/AdminDashboardController.php +++ b/app/Http/Controllers/AdminDashboardController.php @@ -100,32 +100,87 @@ class AdminDashboardController extends Controller return redirect()->back()->with('success', 'Notification deleted successfully!'); } + // Store Student Portal Log + public function storePortalLog(Request $request) + { + $request->validate([ + 'user_id' => 'required|exists:users,id', + ]); + + return $this->sendToPortalLog($request->user_id); + } + // Send User to Portal Log public function sendToPortalLog($userId) { try { $user = User::findOrFail($userId); - // Check if user is already logged + // User දැනටමත් Portal Log එකේ සිටීදැයි පරීක්ෂා කිරීම $exists = StudentPortalLog::where('user_id', $user->id)->exists(); if ($exists) { return redirect()->back()->with('error', 'This user is already in Portal Logs!'); } - // Create new portal log + // Student Portal Log එකට පමණක් Data Insert කිරීම StudentPortalLog::create([ 'user_id' => $user->id, 'first_name' => $user->first_name ?? '', 'last_name' => $user->last_name ?? '', 'email' => $user->email, 'phone' => $user->phone ?? null, + 'pin' => null, ]); return redirect()->back()->with('success', 'User successfully added to Portal Logs!'); + } catch (Exception $e) { \Log::error('Send to Portal Log Error: ' . $e->getMessage()); - return redirect()->back()->with('error', 'Failed to add user to Portal Log.'); + return redirect()->back()->with('error', 'Failed to add user to Portal Log: ' . $e->getMessage()); } } + + // Update or Delete User Portal PIN + public function updatePin(Request $request, $id) + { + $request->validate([ + 'pin' => 'nullable|string|max:20', + ]); + + try { + $portalLog = StudentPortalLog::findOrFail($id); + $portalLog->pin = $request->filled('pin') ? $request->pin : null; + $portalLog->save(); + + $message = $request->filled('pin') + ? 'Portal PIN updated successfully!' + : 'Portal PIN deleted successfully!'; + + return redirect()->back()->with('success', $message); + + } catch (Exception $e) { + \Log::error('Update PIN Error: ' . $e->getMessage()); + return redirect()->back()->with('error', 'Failed to update PIN: ' . $e->getMessage()); + } + } + + // ========================================================================= + // STUDENT PORTAL LOG DELETION ONLY (Main User Account එක ඉතිරි වේ) + // ========================================================================= + + + +public function destroyPortalLog($id) +{ + try { + $portalLog = StudentPortalLog::findOrFail($id); + $portalLog->delete(); // student_portal_logs Table එකෙන් පමණක් Delete වේ + + return redirect()->back()->with('success', 'Student Portal access record deleted successfully!'); + } catch (Exception $e) { + \Log::error('Delete Portal Log Error: ' . $e->getMessage()); + return redirect()->back()->with('error', 'Failed to remove from Student Portal: ' . $e->getMessage()); + } +} } \ No newline at end of file diff --git a/resources/views/admin/admindashboard.blade.php b/resources/views/admin/admindashboard.blade.php index c9147c0..f1b3ef3 100644 --- a/resources/views/admin/admindashboard.blade.php +++ b/resources/views/admin/admindashboard.blade.php @@ -30,16 +30,22 @@ font-size: 24px; } /* Edit Mode Control Styles */ + /* Edit Mode Control Styles */ .edit-only { display: none !important; } + + /* Display rule based on element types */ .is-editing .edit-only { display: inline-block !important; } .is-editing div.edit-only { display: block !important; } - .is-editing flex.edit-only, + .is-editing td.edit-only, + .is-editing th.edit-only { + display: table-cell !important; + } .is-editing .d-flex.edit-only { display: flex !important; } @@ -53,13 +59,7 @@
Automobile Engineering Academy System Overview
- - - + @@ -320,103 +320,65 @@ - -| ID | +Name | +Phone | +Created Date | +Action | +||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ID | -Name | -Phone | -Portal PIN | -Created Date | -Action | +#{{ $user->id }} | +{{ $user->first_name }} {{ $user->last_name }} | +{{ $user->email }} | +{{ $user->phone ?? 'N/A' }} | +{{ $user->created_at ? $user->created_at->format('Y-m-d H:i') : 'N/A' }} | + ++ + | |
| #{{ $user->id }} | -{{ $user->first_name }} {{ $user->last_name }} | -{{ $user->email }} | -{{ $user->phone ?? 'N/A' }} | - -
-
- @if(!empty($log->pin) && $log->pin !== 'N/A')
-
-
- {{ $log->pin }}
-
-
-
-
-
-
-
- @else
-
-
- N/A
-
-
-
-
- @endif
-
- |
- {{ $log->created_at ? $log->created_at->format('Y-m-d H:i') : 'N/A' }} | -- - | -||||||
| - - No registered users found. - | -||||||||||||