我想多次使用函数loadview()
加载同一视图,以使用其他数据调用数组。我想将第一个$ pdf1添加到第二个$ pdf2。
$pdf = $pdf1 + $pdf2;
将$ pdf1和$ pdf2的所有数据传递到$ pdf以发送到视图。有没有办法做到这一点?
控制器
public function store(Request $request)
{
error_log('Some message here.');
if (!empty ($nbrrowsol)) {
$pdf1 = PDF::loadview('gestion_commandes.myPDF',
['commandesol' => $commandesol, 'nbrrowsol' => $nbrrowsol])->setPaper('a4', 'landscape');
}
if (!empty ($nbrroweau)) {
$pdf2 = PDF::loadview('gestion_commandes.myPDF',
['commandeeau' => $commandeeau, 'nbrroweau' => $nbrroweau])->setPaper('a4', 'landscape');
}
$pdf = PDF::loadview('gestion_commandes.myPDF', [
'clients' => $clients, 'commercial' => $commercial, 'datereception' => $datereception,
'dateprelevement' => $dateprelevement
])->setPaper('a4', 'landscape');
return $pdf->stream('hdtuto.pdf');//redirect('gestion_commandes/create');
}
答案 0 :(得分:0)
public function store(Request $request)
{
error_log('Some message here.');
if (!empty ($nbrrowsol)) {
$pdf1 = PDF::loadview('gestion_commandes.myPDF',
['commandesol' => $commandesol, 'nbrrowsol' => $nbrrowsol])->setPaper('a4', 'landscape');
return $pdf1->stream('hdtuto.pdf');//redirect('gestion_commandes/create');
}
}
if (!empty ($nbrroweau)) {
$pdf2 = PDF::loadview('gestion_commandes.myPDF',
['commandeeau' => $commandeeau, 'nbrroweau' => $nbrroweau])->setPaper('a4', 'landscape');
return $pdf2->stream('hdtuto.pdf');//redirect('gestion_commandes/create');
}
else{
$pdf = PDF::loadview('gestion_commandes.myPDF', [
'clients' => $clients, 'commercial' => $commercial, 'datereception' => $datereception,
'dateprelevement' => $dateprelevement
])->setPaper('a4', 'landscape');
return $pdf->stream('hdtuto.pdf');//redirect('gestion_commandes/create');
}
}