has('admin_id')) { return redirect()->route('admin.login')->with('error', 'Please login first.'); } $totalTimetableSlots = Timetable::count(); $unreadNotifications = Notification::where('target_role', 'admin') ->where('is_read', false) ->count(); $notifications = Notification::where('target_role', 'admin') ->orderBy('created_at', 'desc') ->take(5) ->get(); return view('admin.admindashboard', compact( 'totalTimetableSlots', 'unreadNotifications', 'notifications' )); } public function markAsRead($id) { $notification = Notification::findOrFail($id); $notification->update(['is_read' => true]); return redirect()->back()->with('success', 'Notification marked as read!'); } }