@php $unreadNotificationCount = 0; $currentMeetingCount = 0; if ($isStudentLoggedIn) { $student = $student ?? session('student'); $studentId = \App\Helpers\StudentHelper::id(); if ($student) { $sidebarCacheKey = 'student_sidebar_counts:' . ($studentId ?: 'guest') . ':' . ($student['cname'] ?? '') . ':' . ($student['dept'] ?? '') . ':' . ($student['batch'] ?? ''); $sidebarCounts = \Illuminate\Support\Facades\Cache::remember($sidebarCacheKey, 60, function () use ($student, $studentId) { $unread = 0; $meetings = 0; try { if (class_exists('\App\Models\Notification')) { $notificationIds = \App\Models\Notification::forStudent( $student['uname'], $student['cname'], $student['dept'], $student['batch'] )->where('times', '>=', now()->subDays(30)) ->pluck('id') ->toArray(); if (!empty($notificationIds)) { if ($studentId) { $readCount = \App\Models\NotificationRead::where('student_id', $studentId) ->whereIn('notification_id', $notificationIds) ->count(); $unread = max(0, count($notificationIds) - $readCount); } else { $unread = count($notificationIds); } } } } catch (\Exception $e) { \Log::error('Error getting notification count in sidebar: ' . $e->getMessage()); } try { $studentUname = $student['uname'] ?? null; $studentCname = $student['cname'] ?? null; $studentDept = $student['dept'] ?? null; $studentBatch = $student['batch'] ?? null; $now = \Carbon\Carbon::now('Asia/Kolkata'); $nextHour = $now->copy()->addHour(); $meetings = DB::table('meets') ->where(function($outer) use ($studentUname, $studentCname, $studentDept, $studentBatch) { $outer->where(function($q) use ($studentCname) { $q->where('uname', 'all') ->where('cname', $studentCname) ->where('dept', 'all') ->where('batch', 'all'); }) ->orWhere(function($q) use ($studentCname, $studentDept) { $q->where('uname', 'all') ->where('cname', $studentCname) ->where('dept', $studentDept) ->where('batch', 'all'); }) ->orWhere(function($q) use ($studentCname, $studentDept, $studentBatch) { $q->where('uname', 'all') ->where('cname', $studentCname) ->where('dept', $studentDept) ->where('batch', $studentBatch); }) ->orWhere(function($q) use ($studentUname, $studentCname, $studentDept, $studentBatch) { $q->where('uname', $studentUname) ->where('cname', $studentCname) ->where('dept', $studentDept) ->where('batch', $studentBatch); }); }) ->where(function($q) use ($now, $nextHour) { $q->where(function($q1) use ($now) { $q1->where('start_time', '<=', $now) ->where('end_time', '>=', $now); }) ->orWhere(function($q2) use ($now, $nextHour) { $q2->where('start_time', '>', $now) ->where('start_time', '<=', $nextHour); }); }) ->count(); } catch (\Exception $e) { \Log::error('Error getting meeting count in sidebar: ' . $e->getMessage()); } return ['unread' => $unread, 'meetings' => $meetings]; }); $unreadNotificationCount = $sidebarCounts['unread'] ?? 0; $currentMeetingCount = $sidebarCounts['meetings'] ?? 0; } } $menuItems = [ [ 'title' => 'Dashboard', 'icon' => 'fa-duotone fa-solid fa-house', 'route' => 'student.dashboard.index', ], [ 'title' => 'Course', 'icon' => 'fa-duotone fa-solid fa-graduation-cap', 'route' => 'student.course.index', 'active_routes' => ['student.course.*'], ], [ 'title' => 'Certificates', 'icon' => 'fa-solid fa-award', 'route' => 'student.certificates.index', 'active_routes' => ['student.certificates.*'], ], [ 'title' => 'Attendance', 'icon' => 'fa-sharp-duotone fa-solid fa-calendar-check', 'route' => 'student.attendance.select', 'active_routes' => ['student.attendance.*'], ], [ 'title' => 'Coding Assessments', 'icon' => 'fa-duotone fa-solid fa-laptop-code', 'route' => 'student.codingassessment.index', ], [ 'title' => 'MCQ Assessments', 'icon' => 'fa-duotone fa-solid fa-list-check', 'route' => 'student.mcqassessment.index', ], [ 'title' => 'PlayGround', 'icon' => 'fa-solid fa-laptop-code', 'new_tab' => true, 'route' => 'student.playground.programming.index', ], [ 'title' => 'Break Zone', 'icon' => 'fa-solid fa-gamepad', 'route' => 'student.breakzone.index', 'active_routes' => ['student.breakzone.*'], ], [ 'title' => 'Notifications', 'icon' => 'fa-duotone fa-solid fa-bell', 'route' => 'student.alert.index', 'badge' => $unreadNotificationCount, 'badge_id' => 'alertBadge', ], [ 'title' => 'Doubt Clearance', 'icon' => 'fa-duotone fa-solid fa-question-circle', 'route' => 'student.doubt.index', ], [ 'title' => 'Meet', 'icon' => 'fa-duotone fa-solid fa-video', 'route' => 'student.meet.index', 'badge' => $currentMeetingCount, 'badge_id' => 'meetBadge', 'badge_color' => 'success', ], [ 'title' => 'Feedback', 'icon' => 'fa-duotone fa-solid fa-book-open', 'route' => 'student.feedback.index', ], ]; @endphp @foreach ($menuItems as $item) @if (isset($item['dropdown']))
  • {{ $item['title'] }}
      @foreach ($item['dropdown'] as $sub)
    • @if ($item['title'] === 'Play Ground') {{ $sub['title'] }} @else {{ $sub['title'] }} @endif
    • @endforeach
  • @else
  • {{ $item['title'] }} @if(isset($item['badge']) && $item['badge'] > 0) {{ $item['badge'] > 9 ? '9+' : $item['badge'] }} @elseif(isset($item['badge_id'])) 0 @endif
  • @endif @endforeach