0
I’m using a feature to generate PDF reports using Laravel. However I am in doubt if it is possible from a simple HTML button, to redirect automatically to a function of mine controller without having to create a new route. I would like as an example to put the function and transform it into an object to be called in the view as shown below.
<a href="{{generatePDF()}}" class="btn btn-sm btn-primary">Gerar PDF</a>
How it would happen in Javascript. The function I wish to redirect is this:
function generatePDF(){
$pdf = PDF::loadView('dashboard-pdf',$dados)->setPaper('a4', 'landscape');
return $pdf->stream();
}
Would it be possible to do something similar to Laravel or would even have to create a new route just to perform this function?
It is that I have a large code to add the correct values in $data. And then I thought of some way to reduce that amount of code a little bit. But if you do that, that’s bad practice. I intend to create normal routes anyway.
– Arthur Abitante