Closed zillion42 closed 1 year ago
Some more background. I create the array like so:
foreach ($people as $person) {
$rechnungen = $person->invoices->where('RJ', $rechnungsjahr)->sortByDesc('Produnktionstag');
if (count($rechnungen) > 0) {
$daten[] = [
'person' => $person,
'rechnungen' => $rechnungen
];
}
}
return (new LaraTeX('clerk.clerk_export_tex'))->with($daten)->download('test.pdf');
and try to read it like so, I'm unsure if the access is correct yet, but it doesn't even recognize the array itself:
\begin{textblock}{12}(2.3,6)
\noindent
\begin{tabular}{ll}
@foreach($daten as $person)
SB & {{ $person['person']->Sachbearb }} \\
Name & {{ $person['person']->Nachname }} \\
Vorname & {{ $person['person']->Vorname }} \\
Geburtsdatum & {{ $person['person']->Geboren->isoFormat('DD.MM.YYYY'); }} \\
Stra{\ss}e & {{ $person['person']->Strasse }} \\
Ort & {{ $person['person']->Postleitzahl }} {{ $person['person']->Ort }} \\
ID & {{ $person['person']->id }} \\
\end{tabular}
\end{textblock}
\begin{textblock}{12}(2.45,10)
\noindent
\fontsize{10}{12} \selectfont
\begin{tabular}{|r|r|l|l|l|l|l|l|}
\hline
% __tableHeader__
\hline
\hline
% __tablebody__
\hline
\end{tabular}
\end{textblock}
% ---- End Pages ------
@endforeach
Out of my head I think you would have to pass an array or use compact:
with(['daten', $daten])
or
with(compact('daten'))
compact('daten')
That's how I do it for all other views, and of course it works. Thx again. 🤦 again
@zillion42 You are more then welcome!
I have this kind of array each entry has a model and a collection of models:
I'm passing it to the tex blade like so:
return (new LaraTeX('clerk.clerk_export_tex'))->with($daten)->download('test.pdf');
and I get
Originally posted by @zillion42 in https://github.com/ismaelw/laratex/issues/20#issuecomment-1480981605