Chron
6 months ago

Trying to get property of non-object

Posted 6 months ago by Chron

I'm using barryvdh/laravel-dompdf. When I pass the data of the current user I get the said error.

Controller

public function viewAssessment() {
        $user = Auth::user()->customer;
        $pdf = \PDF::loadView('print', compact('user'));
        return $pdf->stream('invoice.pdf');

    }

View

<ul>
            @foreach($user as $u)
            <li>{{ $u->firstname }}</li>
            @endforeach
</ul>

Please sign in or create an account to participate in this conversation.