@if($data && $data->count() > 0) @php $firstItem = $data->first(); $columns = []; if ($firstItem) { $attributes = $firstItem->getAttributes(); foreach ($attributes as $key => $value) { // Exclude system fields and serial_no (since we have S.No.) if (!in_array($key, ['id', 'application_id', 'created_at', 'updated_at', 'deleted_at', 'serial_no'])) { $columns[] = $key; } } } @endphp @foreach($columns as $column) @endforeach @foreach($data as $index => $item) @foreach($columns as $column) @endforeach @endforeach
S.No.{{ ucwords(str_replace('_', ' ', $column)) }}
{{ $index + 1 }} @if($item->$column instanceof \Carbon\Carbon) {{ $item->$column->format('M d, Y') }} @elseif(is_numeric($item->$column) && $column === 'amount') ₹{{ number_format($item->$column, 2) }} @else {{ $item->$column ?? 'N/A' }} @endif
@else
No data available for this section
@endif