after upgrade from Laravel 6 to 9, i have this error...
Below is my code that produce the error:
$pdf = PDF::loadView('general.layouts.pdf.receipt_paid');
$pdf_name = "PAID RECEIPT_123456";
$pdf_stream = $pdf->stream($pdf_name);
Mail::send('general.email.receipt', [], function($message) use($pdf_stream, $pdf_name){
$message->to("johndoe@gmail.com")
->subject('Your Order (123456) Has Been Paid')
->attachData($pdf_stream, $pdf_name, [
'mime' => 'application/pdf'
]);
});
I don't have any idea what is the mistake I made... or do I need to amend something after upgrade to version 9?
I already try use Mailable
class instead, but still occurred the same error.
I just solved the problem...
Actually it is not related with Laravel upgrade...
But actually it has problem with barryvdh/laravel-dompdf
newer version...
After upgrade laravel-dompdf
, I need to use $pdf->output()
instead of $pdf->stream($pdf_name)
..
Then my problem solved..
The solution is based on this question actually: https://stackoverflow.com/a/60947707/5179633