@php // Default to empty array if not passed $excludedColumns = $excludedColumns ?? []; // Dynamically extract columns, excluding the passed ones $columns = $items->flatMap(fn($row) => array_keys($row->toArray())) ->unique() ->reject(fn($col) => in_array($col, $excludedColumns)) ->toArray(); @endphp {{-- Dynamic Table --}} @foreach ($columns as $label) @endforeach @foreach ($items->toArray() as $row) @foreach ($columns as $column) @endforeach @endforeach
{{ $label }}
{{ $row[$column] ?? 'N/A' }}