0
The doubt is the following, in my PDF generator, when I click on generate, it generates a pdf with all the information that is contained in the tables of the database, so I’m in doubt dom how to pass only the array, which is found when a search is made.
Example:
This is my screen with all the information, if I click on Download pdf, the generated pdf will have all this information.
Below is the search screen where I came only one information:
Now if I click on Download PDF, it will generate a pdf with all the information and not only with what was searched.
A modification that I thought for him to generate the pdf only with the researched information, is to pass the array that contains the information of the tables as parameter for the generation of the URL:
HTML, button that generates pdf:
<p>
<a href="{{ action('CatracaControler@metodopdf', $catraca) }}">Download em PDF</a>
</p>
My Route:
Route::any('/listar/pdf/{$catraca}', 'CatracaControler@metodopdf')->name('Relatorio');
The Query Request function, is the one that returns the search array:
public function lista(Request $request){
$aux = $request->texto;
$catraca = Catraca::where('MATRICULA', 'like', '%'.$aux.'%')->orWhere('NOME', 'like', '%'.$aux.'%')->orWhere('NUM_CARTAO', 'like', '%'.$aux.'%')->orWhere('MATRICULA', 'like', '%'.$aux.'%')->get();
return view('catraca.listagem')->with('catraca', $catraca);
}
And the function of generating the pdf that receives as parameter the array that was generated in the function above.
public function metodopdf($catraca){
return \PDF::loadView('catraca.layoutpdf', compact('catraca'))->setPaper('a4', 'landscape')->stream('relatorio.pdf');
}
But this generates me the following error on the route:
Error message says the route is wrong due to lack of parameters.
My question is: Is it possible to pass an array as a parameter for routes? To be captured by the function Generate pdf?
appeared this way: "Too few Arguments to Function App Http Controllers Ratcheacontroler::metodopdf(), 0 passed and Exactly 1 expected"
– Daniel Rosendo de Souza
The action expects an action array('Catracacontroler@metodopdf', [$chavepesquisa]), already corrected in the example
– Jorge Costa