{{--
  • --}} @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; 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

    {{ $unreadCount >= 20 ? '20+' : $unreadCount }} New
    @forelse($recentNotifications as $notification)
    @php $iconMap = [ 'loan_application' => 'bx-credit-card text-success', 'payment' => 'bx-money text-info', 'deduction_add' => 'bx-line-chart text-info', 'membership' => 'bx-user-plus text-primary', 'withdrawal' => 'bx-log-out text-danger', 'refund' => 'bx-undo text-warning', 'benefit' => 'bx-gift text-success', 'condolence' => 'bx-heart text-danger', 'retirement' => 'bx-briefcase text-secondary', 'share_enquiry' => 'bx-trending-up text-success', 'withdraw_savings' => 'bx-wallet-alt text-danger', 'withdraw_deposit' => 'bx-transfer-alt text-danger', 'unjoin_membership' => 'bx-user-minus text-danger', 'ura_mobile' => 'bx-mobile-alt text-primary', 'sick_for_30_days' => 'bx-first-aid text-warning', 'injured_at_work' => 'bx-hard-hat text-warning', 'residential_disaster' => 'bx-buildings text-danger', 'join_membership' => 'bx-user-plus text-primary', ]; $enquiryType = $notification->enquiry->type ?? 'default'; $iconClass = $iconMap[$enquiryType] ?? 'bx-bell text-primary'; @endphp
    {{ Str::limit($notification->title, 35) }}

    {{ $notification->created_at->diffForHumans() }} @if($notification->enquiry) • {{ $notification->enquiry->region->name ?? 'N/A' }}, {{ $notification->enquiry->district->name ?? 'N/A' }} @endif

    @if(!$notification->is_read) New @endif
    @empty

    No notifications

    @endforelse
    View All Notifications
  • @endif @if(auth()->check() && auth()->user()->hasAnyRole(['superadmin', 'system_admin']))
  • @endif
{{ substr(Auth::user()->name, 0, 1) }}

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

@if(Auth::user()->roles->isNotEmpty()) {{ Auth::user()->roles->first()->name }} @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