0
votes

I want convert html file to pdf with laravel-snappy but i got message

Parse error: syntax error, unexpected '$pdf' (T_VARIABLE)

This is my code

public function pdf($id){
      $data['data'] = DB::table('data_peminjaman')
                        ->join('inventaris', 'data_peminjaman.id_invetaris', '=', 'inventaris.id')
                        ->where('data_peminjaman.iid', $id)
                        ->get();

      $nama = DB::table('data_peminjaman')
                        ->select('inventaris.name')
                        ->join('inventaris', 'data_peminjaman.id_invetaris', '=', 'inventaris.id')
                        ->where('data_peminjaman.iid', $id)
                        ->get();

      $tgl = DB::table('data_peminjaman')
                        ->select('tgl_pinjam')
                        ->where('iid', $id)
                        ->get();

      $namafile = $nama+'-'+$tgl+'.pdf'
      $pdf = PDF::loadView('pdf.surat', $data);
      return $pdf->download($namafile);
    }
1
You're missing a semicolon on the previous line, after +'.pdf'. And as an aside, PHP uses . to concatenate strings, not +. - user149341

1 Answers

1
votes

Your way of concatenation is wrong. In PHP .(dot) is used to concatenate two strings. modify your code with below code :

$namafile = $nama.'-'.$tgl.'.pdf';