@if($data && $data->count() > 0)
| S.No. | @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){{ ucwords(str_replace('_', ' ', $column)) }} | @endforeach
|---|---|
| {{ $index + 1 }} | @foreach($columns as $column)@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 | @endforeach