【问题标题】:Laravel5 vsmoraes/pdf-laravel5 errorsLaravel5 vsmoraes/pdf-laravel5 错误
【发布时间】:2016-02-11 13:03:41
【问题描述】:

我正在使用this 库。所以我在下载时遇到了这个错误

未定义变量:cv_info

这是我的控制器

public function downloadPDF()
    {
        $url=Input::get('url');
        $url=explode('/', $url);
        $cv_id = substr($url[4], 0, -13);
        $name=Auth::user()->username;
        $cv_info=CV::where('id','=',$cv_id)->first();
        $html = view('ui.userinfo.viewCV',$cv_info)->render();

        return $this->pdf
        ->load($html)
        ->show();
    }

我已经通过 $cv_info 来查看为什么我有这个错误。感谢帮助

$html = view('ui.userinfo.viewCV',$cv_info)->render();

【问题讨论】:

    标签: laravel pdf laravel-5


    【解决方案1】:

    你没有正确传递它。

    $html = view('ui.userinfo.viewCV')->with('cv_info', $cv_info);
    

    或者你可以使用

    $html = view('ui.userinfo.viewCV', ['cv_info' => $cv_info])->render();
    

    【讨论】:

    • -我正在使用第一种方法,我将在 UserController.php 第 190 行收到此错误 FatalErrorException:调用字符串上的成员函数 render() -第二种方法我将收到此错误 ErrorException frame_decorator.cls.php 第 573 行:DOMNode::cloneNode(): ID mainArea 已定义
    • 显然你不能在with 之后调用render,这是一种奇怪的行为,但无论如何你都不应该需要它。看起来它有效,现在您在其他地方出现错误。
    猜你喜欢
    • 1970-01-01
    • 2017-07-07
    • 2017-05-07
    • 2018-01-20
    • 2020-02-13
    • 2015-11-18
    • 2015-11-24
    • 2015-07-27
    • 2015-08-06
    相关资源
    最近更新 更多