Laravel Undefined variable: quote

  javascript, laravel, php, undefined, variables

I am creating a PDF where I will need to display a range of data from customers. I have routes set up to load the PDF which work, and a controller to display the view, however i repeatedly get "Undefined variable: test" when trying to pass in data. I have tried methods given on stack overflow without success, and even when I dd($quote) in the controller, I get the data so I know it is there.


Route::get('tests/{test}/generate-pdf', [TestsController::class, 'generatePdf'])->name('tests.generate-pdf');


public function generatePdf(Test $test)
    $pdf = PDF::loadView('pdf.test');

    return $pdf->inline('test.pdf', [
        'test' => $test,

Blade file:

<div class="">
    <label>Customer: </label>{{ $test->friendly_name }}

Source: Laravel

Leave a Reply