@if($data)
@if(is_object($data) && method_exists($data, 'count') && $data->count() > 0)
| S.No. |
@php
$firstItem = $data->first();
$columns = [];
if ($firstItem) {
if (method_exists($firstItem, 'getAttributes')) {
$attributes = $firstItem->getAttributes();
} else {
$attributes = (array) $firstItem;
}
foreach ($attributes as $key => $value) {
// Exclude system fields, file paths, status columns, and serial_no (since we have S.No.)
$excludeFields = [
'id', 'application_id', 'created_at', 'updated_at', 'deleted_at',
'file_path', 'document_path', 'attachment_path', 'image_path',
'status', 'files_uploaded', 'file_name', 'document_name',
'photo_path', 'signature_path', 'cv_path', 'resume_path',
'serial_no' // Exclude serial_no to avoid duplicate with S.No.
];
if (!in_array($key, $excludeFields) && !str_contains($key, '_path') && !str_contains($key, '_file')) {
$columns[] = $key;
}
}
}
@endphp
@foreach($columns as $column)
{{ ucwords(str_replace('_', ' ', $column)) }} |
@endforeach
@foreach($data as $index => $item)
| {{ $index + 1 }} |
@foreach($columns as $column)
@php
$value = null;
if (is_object($item)) {
if (method_exists($item, 'getAttribute')) {
$value = $item->getAttribute($column);
} elseif (property_exists($item, $column)) {
$value = $item->$column;
}
} elseif (is_array($item)) {
$value = $item[$column] ?? null;
}
@endphp
@if($value instanceof \Carbon\Carbon)
{{ $value->format('M d, Y') }}
@elseif(is_numeric($value) && $column === 'amount')
₹{{ number_format($value, 2) }}
@elseif(is_bool($value))
{{ $value ? 'Yes' : 'No' }}
@else
{{ $value ?? 'N/A' }}
@endif
|
@endforeach
@endforeach
@elseif(is_object($data) && !method_exists($data, 'count'))
@php
if (method_exists($data, 'getAttributes')) {
$attributes = $data->getAttributes();
} else {
$attributes = (array) $data;
}
@endphp
@foreach($attributes as $key => $value)
@php
$excludeFields = [
'id', 'application_id', 'created_at', 'updated_at', 'deleted_at',
'file_path', 'document_path', 'attachment_path', 'image_path',
'status', 'files_uploaded', 'file_name', 'document_name',
'photo_path', 'signature_path', 'cv_path', 'resume_path'
];
$shouldExclude = in_array($key, $excludeFields) || str_contains($key, '_path') || str_contains($key, '_file');
@endphp
@if(!$shouldExclude)
| {{ ucwords(str_replace('_', ' ', $key)) }} |
@if($value instanceof \Carbon\Carbon)
{{ $value->format('F d, Y') }}
@elseif(is_numeric($value) && $key === 'amount')
₹{{ number_format($value, 2) }}
@elseif(is_bool($value))
{{ $value ? 'Yes' : 'No' }}
@else
{{ $value ?? 'N/A' }}
@endif
|
@endif
@endforeach
@elseif(is_array($data))
@if(count($data) > 0)
@php
$isAssociative = array_keys($data) !== range(0, count($data) - 1);
@endphp
@if($isAssociative)
@foreach($data as $key => $value)
| {{ ucwords(str_replace('_', ' ', $key)) }} |
@if(is_array($value) || is_object($value))
{{ json_encode($value) }}
@elseif(is_bool($value))
{{ $value ? 'Yes' : 'No' }}
@else
{{ $value ?? 'N/A' }}
@endif
|
@endforeach
@else
@foreach($data as $item)
- {{ $item }}
@endforeach
@endif
@else
No data available
@endif
@else
{{ $data }}
@endif
@else
No data available for this section
@endif