douwei1950 2019-01-25 09:45 采纳率: 0%
浏览 97

使用Laravel的PDF是空的

I'm trying to download a PDF with all my register user email. The problem is that when i download the PDF, he is empty

I have a controller that create the PDF and with a compact i send all my data to my view. In my view i display all the data with a foreach

When i print_r the data in my controller, it work, but in my pdf i have nothing. So i think the problem comes from the compact

  public function generatePDF(int $id)

{

    $inscrit = Like::where('type',3)->where('id_event' , $id )->first();

    $pdf = PDF::loadView('myPDF',  compact('inscrit'));

    return $pdf->download('Inscrits.pdf'); 

} 


<!DOCTYPE html>

<html>

<head>

    <title>Inscrits</title>

</head>

<body>

    <h1> Inscrits pour l'événement : </h1>



</body>

</html>


<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
      <tr>
        <td>



    {{$inscrit->email}}

        <td>

        </td>
      </tr>
  </body>
</html>
  • 写回答

1条回答 默认 最新

  • duanqiang3925 2019-01-25 09:55
    关注

    Just try to dd your $inscrit variable like dd($inscrit) just to know that you fetch the data.

    and you say you want to get all register user but your query is using the first() method. try to use get()

    评论

报告相同问题?

悬赏问题

  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示