Rolls Report

@php // Grab headers from the first row $firstRow = $data[0] ?? []; if (is_object($firstRow) && method_exists($firstRow, 'toArray')) $firstRow = $firstRow->toArray(); $firstRow = (array) $firstRow; $headers = array_keys($firstRow); // Normalizer for any cell $normalize = function ($v) { if (is_null($v)) return ''; if ($v instanceof \Carbon\CarbonInterface) return $v->toDateTimeString(); if ($v instanceof \DateTimeInterface) return $v->format('Y-m-d H:i:s'); if (is_bool($v)) return $v ? '1' : '0'; if (is_scalar($v)) return (string) $v; if (is_array($v)) { // stringify array values (scalars as-is, nested as JSON) return implode(', ', array_map(function ($x) { if (is_null($x)) return ''; if (is_scalar($x)) return (string) $x; return json_encode($x, JSON_UNESCAPED_UNICODE); }, $v)); } // objects or anything else → JSON return json_encode($v, JSON_UNESCAPED_UNICODE); }; @endphp @foreach($headers as $h) @endforeach @foreach($data as $row) @php // make row array-like if (is_object($row) && method_exists($row, 'toArray')) $row = $row->toArray(); $row = (array) $row; @endphp @foreach($headers as $h) @endforeach @endforeach
{{ ucfirst($h) }}
{{ $normalize($row[$h] ?? '') }}