@props([ 'data' => [ [ 'col1' => 1, 'col2' => 2, 'col3' => 3, ], ], 'showIndex' => false, ]) @php // we derived the table heading based on each object key $columns = count($data) > 0 ? array_keys($data[0]) : []; @endphp
Bil | @endif @foreach ($columns as $column){{ ucfirst(str_replace('_', ' ', $column)) }} | @endforeach
---|---|
{{ $index + 1 }} | @endif @foreach ($columns as $column){{ $row[$column] }} | @endforeach