Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

melx's avatar
Level 4

Call Function to another Function

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 ?

0 likes
3 replies
gokulkhatiwada's avatar

You won’t be having those variables in print function, if you are rendering table than just use datatable

Please or to participate in this conversation.