mardi 13 novembre 2018

How to send response from another function without redirecting Laravel

I have a route like this

Route::get('/downloadReport', 'ReportsController@downloadPdf')->name('downloadReport');

In ReportsController in the function downloadPdf I want to switch respond function as based on input parameter reportType

public function downloadPdf(Request $request){
   $id = $request->input('reportType');
    // some statements are there 
   switch($id){
     case 1: 
       $this->createReportType1($jobId, $cusName);
     break;
   }
}

and the response should be delivered to the user via this function

public function createReportType1($jobId, $cusName){
  $pdf = PDF::loadView('reports.reports',
            compact(
                'jobId',
                'cusName'
            )
        );

        return $pdf->download('invoice.pdf');
}

but I didn't get any output by doing this.. what is the reason and how should I achieve this without returning a value from createReportType1 to downloadPdf function



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire