@extends('layouts.user') @section('title', 'User Dashboard') @section('content') @php $user = Auth::user(); // Check if user has any roles - if not, redirect to role selection // $currentRoleSlug is provided by RoleComposer if (!$currentRoleSlug) { // User has no roles, redirect to a page where they can apply for roles echo ''; exit; } // Calculate real statistics $totalDocs = \App\Models\PortalUserDoc::where('portal_user_id', $user->id)->count(); $uploadedDocs = \App\Models\PortalUserDoc::where('portal_user_id', $user->id) ->whereNotNull('document_path') ->count(); // State change requests $stateChangeRequests = \App\Models\StateChangeRequest::where('user_id', $user->id)->count(); $pendingStateChanges = \App\Models\StateChangeRequest::where('user_id', $user->id) ->where('status', 'pending') ->count(); // Profile completion calculation $profileFields = ['fname', 'lname', 'email', 'mobile', 'dob', 'gender', 'address', 'pincode']; $filledFields = 0; foreach($profileFields as $field) { if(!empty($user->$field)) $filledFields++; } $profileCompletion = round(($filledFields / count($profileFields)) * 100); // Membership status $membershipValid = false; $daysUntilExpiry = 0; if($user->valid_up_to) { $expiryDate = \Carbon\Carbon::parse($user->valid_up_to); $daysUntilExpiry = now()->diffInDays($expiryDate, false); $membershipValid = $daysUntilExpiry > 0; } @endphp

Welcome back, {{ $user->fname ?? $user->name }}!

@if($user->currentRole) You're currently acting as: {{ $user->getCurrentRoleDisplayName() }} @else Please select a role to get started @endif

Active Roles

{{ $user->activeRoles->count() }}

@if($user->currentRole) Current: {{ $user->currentRole->display_name }} @else No role selected @endif

Documents

{{ $uploadedDocs }}/{{ $totalDocs }}

{{ $totalDocs > 0 ? round(($uploadedDocs/$totalDocs)*100) : 0 }}% uploaded

State Changes

{{ $pendingStateChanges }}/{{ $stateChangeRequests }}

{{ $pendingStateChanges }} pending

Profile

{{ $profileCompletion }}%

Completed

Your Roles

You have {{ $user->activeRoles->count() }} active roles

Manage Roles
Profile Management

{{ $profileCompletion }}% profile completed

Edit Profile
Documents

{{ $uploadedDocs }} of {{ $totalDocs }} uploaded

View Documents
Role-specific Information
@if($user->currentRole) @switch($user->currentRole->name) @case('athlete')
Training Information
Belt Check your current belt status
Events Browse upcoming competitions
Achievements

View your certificates and competition history in the Events section.

@break @case('coach')
Coach Resources

Access training materials and team management tools.

License Info

Keep your coaching license up to date.

@break @case('referee')
Referee Duties

Check your assigned matches and competitions.

Certification

Manage your referee certification status.

@break @default
{{ $user->currentRole->display_name }} Dashboard

{{ $user->currentRole->description }}

@endswitch @else
No Role Selected

Please select a role to access role-specific features.

Select Role
@endif
Account Information
Registration UID {{ $user->reg_uid }}
Account Status @if($user->approved == 1 && $user->paid == 1) Active & Verified @elseif($user->approved == 0 && $user->paid == 1) Pending Verification @elseif($user->paid == 0) Payment Pending @else Inactive @endif
Member Since {{ $user->created_at->format('d M, Y') }}
Membership Validity @if($membershipValid) {{ $user->valid_up_to ? \Carbon\Carbon::parse($user->valid_up_to)->format('d M, Y') : 'N/A' }} @if($daysUntilExpiry <= 30) {{ $daysUntilExpiry }} days left @endif @else Expired @endif
Profile Completion {{ $profileCompletion }}%
@endsection