title: Attach generate pdf into mail in Laravel
body: <p>I've some problem with email attach generate pdf, hope you can give me some advice, please kindly help.</p>
  
  <p><strong>Here is the Controller:</strong></p>
  
  <pre><code>public function kirim(Request $request){
      $keluhan = keluhan::findOrFail($request-&gt;id);
  
      $tindak = DB::table('tindakans')
      -&gt;join('keluhans','keluhans.id','=','tindakans.id_keluhan')
      -&gt;select(DB::raw('tindakans.id, id_keluhan, perbaikan_sementara, revisi_dokumen, target_verifikasi, ttd_tanggung1,
      ttd_tanggung2'))-&gt;get();
  
      $analisa = DB::table('analisas')
      -&gt;join('tindakans','tindakans.id','=','analisas.id_tindakan')
      -&gt;join('keluhans','keluhans.id','=','tindakans.id_keluhan')
      -&gt;select(DB::raw('id_tindakan, analisa, tindakan, pic, tanggal_pelaksanaan'))-&gt;get();
  
      $pdf = \PDF::loadView('laporan.ptkp',compact('keluhan','tindak','analisa','halaman'));
      //return $pdf-&gt;stream();
  
      $data = array(
          'email_address'=&gt;$request-&gt;email_address,
          'cc'=&gt;$request-&gt;cc,
          'subject'=&gt;$request-&gt;subject,
          'keterangantambahan'=&gt;$request-&gt;keterangantambahan
      );
  
      Mail::send('laporan.kirim', $data, function($message) use($data) {
          $message-&gt;from('christian7andrew@gmail.com', 'PuraBox');
          $message-&gt;to($data['email_address']);
          if($data['cc'] != null){
              $message-&gt;cc($data['cc']);
          }
          $message-&gt;subject($data['subject']);
          $message-&gt;Attach($pdf);
      });
  
      return redirect('/');
  }
  </code></pre>
  
  <p>How can I attach <code>$pdf</code>?</p>