vendredi 1 décembre 2017

Return PDF and Redirect in Laravel

I would like that, in a Laravel Controller, when I finish a method, it download a pdf and redirect to other route.

       $pdf = PDF::loadHTML($html)
          ->setPaper('a4', 'landscape')
          ->setWarnings(false);
          return $pdf->download('deposit.pdf');

       return redirect()->route('devices.index');

If I put return in PDF, the method not redirect. If I remove "return", the PDF does not download. I tried the code below but it not working.

      return redirect()->response()->download($pdf)->route('devices.index');



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire