{{--
  • --}} @if(auth()->check()) @php $user = auth()->user(); $role = $user->getRoleNames()->first(); // Use same logic as NotificationController $recentNotifications = \App\Models\Notification::query(); switch ($role) { case 'Registrar': case 'registrar': $recentNotifications->whereHas('enquiry', function ($q) use ($user) { $q->where('registered_by', $user->id); }); break; case 'registrar_hq': case 'public_relation_officer': case 'superuser': case 'general_manager': // See everything - no filter break; case 'assistant_manager': $recentNotifications->where(function ($q) { $q->where('type', 'payment_initiated') ->orWhere('type', 'loan_processed'); }); break; case 'branch_manager': $recentNotifications->whereHas('enquiry', function ($q) use ($user) { $q->whereHas('registeredBy', function ($subQ) use ($user) { $subQ->where('branch_id', $user->branch_id); }); }); break; case 'loan_officer': case 'loanofficer': case 'Loan_Officer': case 'accountant': case 'Accountant': // Show ONLY assigned enquiries and relevant notification types $recentNotifications->where(function($q) use ($user) { // Notifications for enquiries assigned to this user $q->whereHas('enquiry', function ($subQ) use ($user) { $subQ->whereHas('assignedUsers', function ($assignQ) use ($user) { $assignQ->where('user_id', $user->id); }); }) // OR notifications of specific types related to their work ->orWhereIn('type', [ 'payment_initiated', 'payment_approved', 'loan_processed', 'loan_approved', 'enquiry_assigned' ]); }); break; case 'head_of_department_loan': // Head of Loan Department sees notifications for loan applications assigned to loan officers $recentNotifications->whereHas('enquiry', function ($q) { $q->where('type', 'loan_application') ->whereHas('assignedUsers', function ($subQ) { $subQ->whereHas('roles', function ($roleQ) { $roleQ->where('name', 'loanofficer'); }); }); }); break; case 'head_of_department_accountant': // Head of Accountant Department sees notifications for non-loan enquiries assigned to accountants $recentNotifications->whereHas('enquiry', function ($q) { $q->where('type', '!=', 'loan_application') ->whereHas('assignedUsers', function ($subQ) { $subQ->whereHas('roles', function ($roleQ) { $roleQ->where('name', 'accountant'); }); }); }); break; default: $recentNotifications->where('user_id', $user->id); } // Get UNREAD notifications only $recentNotifications = $recentNotifications ->where('is_read', false) ->with(['enquiry.region', 'enquiry.district', 'enquiry.registeredBy']) ->orderBy('created_at', 'desc') ->limit(20) ->get(); $unreadCount = $recentNotifications->count(); @endphp
  • @if($unreadCount > 0) {{ $unreadCount >= 20 ? '20+' : $unreadCount }} @endif
    Notifications
    @if($unreadCount > 0) {{ $unreadCount }} @endif
    @forelse($recentNotifications as $notification) @php $iconMap = [ 'loan_application' => ['icon' => 'bx-credit-card', 'color' => '#10b981'], 'payment' => ['icon' => 'bx-money', 'color' => '#3b82f6'], 'deduction_add' => ['icon' => 'bx-line-chart', 'color' => '#3b82f6'], 'membership' => ['icon' => 'bx-user-plus', 'color' => '#6366f1'], 'withdrawal' => ['icon' => 'bx-log-out', 'color' => '#ef4444'], 'refund' => ['icon' => 'bx-undo', 'color' => '#f59e0b'], 'benefit' => ['icon' => 'bx-gift', 'color' => '#10b981'], 'condolence' => ['icon' => 'bx-heart', 'color' => '#ef4444'], 'retirement' => ['icon' => 'bx-briefcase', 'color' => '#6b7280'], 'share_enquiry' => ['icon' => 'bx-trending-up', 'color' => '#10b981'], 'withdraw_savings' => ['icon' => 'bx-wallet-alt', 'color' => '#ef4444'], 'withdraw_deposit' => ['icon' => 'bx-transfer-alt', 'color' => '#ef4444'], 'unjoin_membership' => ['icon' => 'bx-user-minus', 'color' => '#ef4444'], 'ura_mobile' => ['icon' => 'bx-mobile-alt', 'color' => '#6366f1'], 'sick_for_30_days' => ['icon' => 'bx-first-aid', 'color' => '#f59e0b'], 'injured_at_work' => ['icon' => 'bx-hard-hat', 'color' => '#f59e0b'], 'residential_disaster' => ['icon' => 'bx-buildings', 'color' => '#ef4444'], 'join_membership' => ['icon' => 'bx-user-plus', 'color' => '#6366f1'], ]; $enquiryType = $notification->enquiry->type ?? 'default'; $iconData = $iconMap[$enquiryType] ?? ['icon' => 'bx-bell', 'color' => '#6366f1']; @endphp
    {{ Str::limit($notification->title, 45) }}
    {{ $notification->created_at->diffForHumans() }} @if($notification->enquiry) • {{ Str::limit($notification->enquiry->region->name ?? '', 10) }} @endif @if($notification->created_at->diffInHours(now()) < 24) New @endif
    @if(!$notification->is_read)
    @endif
    @empty

    No new notifications

    @endforelse
    View All Notifications
  • @endif @if(auth()->check() && auth()->user()->hasAnyRole(['superadmin', 'system_admin']))
  • @endif
{{ substr(Auth::user()->name, 0, 1) }}
{{ Str::limit(Auth::user()->name, 15) }}
@if(Auth::user()->roles->isNotEmpty()) {{ Str::limit(Auth::user()->roles->first()->name, 12) }} @else {{ Auth::user()->designation ?? 'User' }} @endif
{{ substr(Auth::user()->name, 0, 1) }}
{{ Auth::user()->name }}
{{ Auth::user()->email }}
My Profile @if(auth()->user()->hasAnyRole(['superadmin', 'system_admin', 'general_manager'])) Dashboard @endif Settings
Logout
@csrf