【发布时间】:2018-11-25 12:26:01
【问题描述】:
我有这个查询,我使用包“https://github.com/barryvdh/laravel-dompdf”以 pdf 格式显示结果:
public function getRegistrationInfo($regID){
$registration = Registration::with('conference',Conference.registrationTypes','Conference.registrationTypes.participants')
->where('id',$regID)->first();
$pdf = PDF::loadView('pdf.registration', compact('registration'));
return $pdf->download('invoice.pdf');
}
在“pdf.registration”视图中我有这个来显示查询结果:
@foreach($registration->conference->registrationTypes as $key=>$registrationType)
<li>
<span>show the registration ID here : {{$registration->id}}</span> <br>
<span>Conference name {{$registration->conference->name}}</span><br>
<span>Registration type: {{$registration->conference->registrationTypes[$key]['name']}}</span><br>
<span> Participant: {{$registration->conference->registrationTypes[$key]
->participants[0]->name .' '.$registration->
conference->registrationTypes[$key]->participants[0]->surname}}</span><br>
<span>Price: {{$registration->conference->registrationTypes[$key]['price']}}</span><br>
</li>
@endforeach
当用户单击按钮下载 pdf 时,它会工作。现在它返回 2 个结果、2 个列表项,并且这两个列表项都出现在 pdf 的第一页上。但我想将每个列表项放在 pdf 的一页中。你知道实现这一点需要什么?
【问题讨论】: