@extends('layouts.user') @section('title', 'Personal Documents') @section('content') @php // Fetch user documents $userDocs = \App\Models\PortalUserDoc::where('portal_user_id', $user->id)->get(); // Helper function to extract clean file name from path function extractDocFileName($path) { if (empty($path)) return 'N/A'; // Extract just the filename from the full path $filename = basename($path); // Remove file extension for display $nameWithoutExt = pathinfo($filename, PATHINFO_FILENAME); // Replace common separators with spaces $nameWithoutExt = str_replace(['_', '-'], ' ', $nameWithoutExt); // Remove numeric prefixes (timestamps, user IDs) $nameWithoutExt = preg_replace('/^\d+\s*/', '', $nameWithoutExt); // Capitalize each word $displayName = ucwords(strtolower($nameWithoutExt)); // Get file extension $extension = strtoupper(pathinfo($filename, PATHINFO_EXTENSION)); return $displayName . ' (' . $extension . ')'; } // Helper function to mask Aadhaar number (show only last 4 digits) function maskAadhaar($number) { if (empty($number)) return 'N/A'; // Remove any spaces or dashes $clean = preg_replace('/[\s-]/', '', $number); // If it's 12 digits (Aadhaar format) if (strlen($clean) === 12) { $last4 = substr($clean, -4); return 'XXXX-XXXX-' . $last4; } // For other formats, show last 4 characters $last4 = substr($clean, -4); $masked = str_repeat('X', strlen($clean) - 4); return $masked . $last4; } // Helper function to get document type display name from path or type function getDocTypeName($path, $docType = null) { // First, try to extract from filename if ($path) { $filename = strtolower(basename($path)); // Check for common document types in filename if (str_contains($filename, 'aadhar') || str_contains($filename, 'aadhaar')) { return 'Aadhaar Card'; } elseif (str_contains($filename, 'pan')) { return 'PAN Card'; } elseif (str_contains($filename, 'passport')) { return 'Passport'; } elseif (str_contains($filename, 'driving') || str_contains($filename, 'license')) { return 'Driving License'; } elseif (str_contains($filename, 'voter')) { return 'Voter ID'; } elseif (str_contains($filename, 'birth')) { return 'Birth Certificate'; } elseif (str_contains($filename, 'medical')) { return 'Medical Certificate'; } elseif (str_contains($filename, 'photo') || str_contains($filename, 'image')) { return 'Photograph'; } } // Fallback to doc_type if provided if ($docType) { $types = [ 'aadhar' => 'Aadhaar Card', 'pan' => 'PAN Card', 'passport' => 'Passport', 'driving_license' => 'Driving License', 'voter_id' => 'Voter ID', 'birth_certificate' => 'Birth Certificate', 'medical_certificate' => 'Medical Certificate', 'photo' => 'Photograph', 'other' => 'Other Document' ]; return $types[$docType] ?? ucwords(str_replace('_', ' ', $docType)); } return 'Personal Document'; } // Helper function to get document icon function getDocIcon($type) { $icons = [ 'aadhar' => 'credit-card', 'pan' => 'bookmark', 'passport' => 'globe', 'driving_license' => 'truck', 'voter_id' => 'check-square', 'birth_certificate' => 'award', 'medical_certificate' => 'activity', 'photo' => 'image', 'other' => 'file' ]; return $icons[$type] ?? 'file-text'; } // Helper function to get badge color based on document type function getDocBadgeColor($type) { $colors = [ 'aadhar' => 'primary', 'pan' => 'info', 'passport' => 'success', 'driving_license' => 'warning', 'voter_id' => 'secondary', 'birth_certificate' => 'info', 'medical_certificate' => 'danger', 'photo' => 'secondary', 'other' => 'dark' ]; return $colors[$type] ?? 'secondary'; } // Calculate document statistics $totalDocs = $userDocs->count(); $uploadedDocs = $userDocs->filter(function($doc) { return !empty($doc->document_path); })->count(); // Check for expiring documents (within 30 days) $expiringDocs = $userDocs->filter(function($doc) { if (!empty($doc->date_of_expiry)) { $expiryDate = \Carbon\Carbon::parse($doc->date_of_expiry); $daysLeft = now()->diffInDays($expiryDate, false); return $daysLeft >= 0 && $daysLeft <= 30; } return false; })->count(); @endphp

Personal Documents

Manage your personal identification and official documents
Back to Documents
Total Documents

{{ $totalDocs }}

Uploaded

{{ $uploadedDocs }}

Expiring Soon

{{ $expiringDocs }}

@if($userDocs->where('document_type', 'aadhar')->count() > 0) @endif @if($totalDocs > 0)
@foreach($userDocs as $doc)
{{ getDocTypeName($doc->document_path, $doc->document_type) }}
{{ strtoupper($doc->document_type) }} @if(!empty($doc->document_path))
{{ extractDocFileName($doc->document_path) }}
@endif
Document Number: @if($doc->document_type === 'aadhar') {{ maskAadhaar($doc->document_no) }} @else {{ $doc->document_no ?? 'N/A' }} @endif
@if($doc->date_of_issue)
Issue Date: {{ \Carbon\Carbon::parse($doc->date_of_issue)->format('d M, Y') }}
@endif @if($doc->date_of_expiry)
Expiry Date:
{{ \Carbon\Carbon::parse($doc->date_of_expiry)->format('d M, Y') }} @php $expiryDate = \Carbon\Carbon::parse($doc->date_of_expiry); $daysLeft = now()->diffInDays($expiryDate, false); @endphp @if($daysLeft > 30) Valid @elseif($daysLeft > 0) {{ round($daysLeft) }} days @else Expired @endif
@endif
Upload Status: @if(!empty($doc->document_path))
Uploaded {{ \Carbon\Carbon::parse($doc->updated_at)->format('d M, Y h:i A') }}
@else
Pending
@endif
@if(!empty($doc->document_path))
@endif
@endforeach
@else
No Documents Found

You haven't uploaded any personal documents yet.

Go to Dashboard
@endif
@endsection