Reputation: 99
I want to download a blade. I am using dompdf.
public function download($id)
{
$booking=Booking::where('id',$id)->first();
$pdf = PDF::loadView('pages.booking.bookingdetails',$booking);
return $pdf->download('bookingdetails.pdf');
}
bookingdetails.blade.php
<div class="container">
<div class="card">
<div class="card-header">
Invoice # {{$booking->id}}
<strong>01/01/01/2018</strong>
<span class="float-right"> <strong>Status:</strong> Pending</span>
</div>
</div>
</div>
So what I want to do is passing the $booking
variable from the method and send to the view. Then download it as a pdf file.
But the error is:
"Undefined variable: booking
Upvotes: 0
Views: 139
Reputation: 41
You need to pass an array as the second argument to the view with the index name of booking
so try this:
$pdf = PDF::loadView('pages.booking.bookingdetails',['booking' => $booking]);
Upvotes: 1
Reputation: 2844
I'm shooting in the dark here, shouldn't it be:
$pdf = PDF::loadView('pages.booking.bookingdetails', ['booking' => $booking]);
Upvotes: 3