DOMPDF loadView() error - undefined variable: data

本小妞迷上赌 提交于 2019-11-29 14:07:53

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

RANJITH

Use compact('data') instead of $data.

Example:

$pdf = \PDF::loadView('productType.invoice', compact('data'));
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!