Aug 31, 2021
0
Level 3
DomPDF issue with eloquent
Hello Guys, I'm having bit of a wired problem with Barryvdh\DomPDF. My Controller file has a function like this:
public function test(){
$data = [
'name' => "John Doe",
'credit' => 15.75,
];
$pdf = PDF::loadView('certificates.test', $data)->setPaper('a4', 'landscape');
return $pdf->stream();
}
Its working fine. However, when I add any eloquent query, even though data is not being used anywhere, its showing "HTTP ERROR 500"
public function test(){
$certificate = Certificate::findOrFail(16);
// Or any other model or DB::table('users') query causing the same issue.
// dd($certificate); or other results showing here alright
$data = [
'name' => "John Doe",
'credit' => 15.75,
];
$pdf = PDF::loadView('certificates.test', $data)->setPaper('a4', 'landscape');
// stream/save/download is not working if any query present
return $pdf->stream();
}
I'm getting certificate data with dd(), so no problem there. Also log file is empty. And worth mentioning that, everything working on local machine.
Would you please give me an idea what might get wrong? Thanks in advance.
Please or to participate in this conversation.