DOMPDF loadView() error - undefined variable: data

后端 未结 2 990
旧时难觅i
旧时难觅i 2021-01-17 18:50

I\'m currently trying to incorporate the DOMPDF Wrapper for Laravel into my project, however I\'m having troble figuring out how to pass a variable into the PDF template.

2条回答
  •  心在旅途
    2021-01-17 19:19

    The loadView method you are using is going to use the extract method before passing the data to the views. This method extracts all the array elements, and creates variables for them based on the key of the element

    This means that your array keys are going to be your variable names, ie $name and not $data->name. This is fairly standard in laravel, for example when using Blade Views.

    http://php.net/manual/en/function.extract.php

提交回复
热议问题