Dompdf LoadView变量传递

问题描述 投票:0回答:1

我无法加载能够将参数传递给dompdf函数LoadView。

这是我的控制器:

  public function pst_affluiti(){

    $data=DB::all('Anagrafica')->get();
    $pdf = PDF::loadView('output',['data' => $data]);
  return $pdf->stream('output.pdf');
  }

我的output.blade.php

<body>
 <div class="container">
<table class="table table-sm table-bordered" >
  <thead>
    <tr>
      <th scope="col-sm-1 col-6">Data Affl.</th>
      <th scope="col-sm-2">Cron.</th>
      <th scope="col-sm-2">Cognome</th>
      <th scope="col-sm-2">Nome</th>
      <th scope="col-sm-2">Data nac.</th>
    </tr>   
  </thead>
 <tbody>
        @foreach($data as $row)
            <tr>
               <td>{{$row->Cron}}</td>
               <td>{{$row->Surname}}</td>
               <td>{{$row->Name}}</td>
               <td>{{$row->Date}}</td>
            </tr>
           @endforeach 
         </tbody>
</table>
</div>
</body>

如果我加载我的查询的正常视图,它运作良好。

有什么建议?提前致谢

laravel-5
1个回答
0
投票

您可以使用

紧凑(“数据”)

代替

$数据

© www.soinside.com 2019 - 2024. All rights reserved.