I am using laravel 4.2 barryvdh/laravel-dompdf. I want to have button for print my PDF. My routes:
Route::resource('orders', 'OrderController');
In OrderController I have method:
public function printpdf($id)
{
$order = Order::find($id);
$pdf = PDF::loadView('print.en', $order);
return $pdf->download($order->id .' '. $order->created_at);
}
I can to call that method from my show.blade.php
. I am using this link:
<a class="btn btn-small btn-danger" href="{{URL::to('orders/' . $order->id . '/printpdf')}}">Print PDF</a>
What route I must have to make this work? I want to make a function which takes a record from my MySQL database and prints it as PDF. How to use this correctly?