Level 56
Try changing this:
$pdf = PDF::loadView('invoices.print', ['invoice' => $invoice] );
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, Using DOMPDF
Route
Route::get('/pdf/{invoice}', [App\Http\Controllers\InvoiceController::class, 'getPDF'])->name('invoice.pdf');
Function
public function getPDF(Invoice $invoice)
{
$pdf = PDF::loadView('invoices.print', $invoice );
return $pdf->download('file.pdf');
}
Blade
<table class="table">
<tr>
<td><strong>Payment Day: {{$invoice->date}}</strong></td>
</tr>
<tr>
<td><strong>INVOICE#: {{$invoice->invoice_number}}</strong></td>
</tr>
<tr>
<td><strong>Buyer: {{$invoice->name}}</strong></td>
</tr>
</table>
Getting error Undefined variable $invoice
How do you import css? With asset()? Use public_path() instead.
Please or to participate in this conversation.