Level 2
You won’t be having those variables in print function, if you are rendering table than just use datatable
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have a function public function search (Request $request), which i search data and display in view blade, and on my blade view i design the print button
but i want to know how i can call this function search to print that data , i have already dompdf package.
Search function
public function searchstockview(Request $request) {
$search=DB::select(DB::raw("SELECT products.id, (select ifnull(sum(loadings.qty),0) from loadings
where
loadings.pid=products.id and
DATE(loadings.Outdate) <= STR_TO_DATE('$date1','%d,%m,%Y')) as total_loadings_till_date,"
from products ));
return view('report.searchstockview',compact('stocksummary','startdate','enddate'));
}
i want to call above function and print, when click button on my blade
public function print(){
$pdf = PDF::loadView('report.stocksummaryprint',compact('stocksummary','startdate','enddate'))- >searchstockview($request);
return $pdf->download('stock Summary.pdf');
}
and how on web route will be ?
Please or to participate in this conversation.