The question is as follows, in my PDF generator, when I click generate, it generates a pdf with all the information that is contained in the database tables, so I am in doubt how to only pass the array, which is found when a search is done.
Example:
Thisismyscreenwithalltheinformation,ifIclickonDownloadpdf,thegeneratedpdfwillhaveallthisinformation.
BelowisthesearchscreenwhereIcamejustaninfo:
NowifIclickonDownloadPDF,itwillgenerateapdfwithalltheinformationandnotjustwhatitwassearchedfor.
AmodificationthatIthoughttogeneratethepdfwithonlytheinformationsearched,istopassthearraythatcontainstheinformationofthetablesasaparameterforthegenerationoftheURL:
HTML,buttonthatgeneratespdf:
<p><ahref="{{ action('CatracaControler@metodopdf', $catraca) }}">Download em PDF</a>
</p>
My Route:
Route::any('/listar/pdf/{$catraca}', 'CatracaControler@metodopdf')->name('Relatorio');
The Search Request function is the one returned by 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 a parameter the array that was generated in the above function.
public function metodopdf($catraca){
return \PDF::loadView('catraca.layoutpdf', compact('catraca'))->setPaper('a4', 'landscape')->stream('relatorio.pdf');
}
But this gives me the following error in the route:
The error message says that the route is wrong due to missing parameters.
My question is: Is it possible to pass an array as a parameter to routes? To be captured by the Generate pdf function?