dt3358 2015-04-30 21:49
浏览 53
已采纳

在对mandril的api-call中使用laravel-view

Ok, so I'm setting up a call to send an email using the mandrill-wrapper from packagist (rather than the build in mandrill-driver) since I want to use merge-vars.

So I set up my view and filled it. It renders correctly, all variables are set up and all is good (I test this by returning the view and see it's good).

next I set up $message, merge_vars- and to-array to send to my mandrill-object.

For $message["html"] I simply put

$message = array(
        'html' => View::make(
             'emails.wishlist.share',
             array(
               'name'=>Auth::user()->fName, 
               'list'=>$list));
...
);

if I just return the view, I can see it renders correctly, but when I actually make the api-call, I can see in the api-log, that the html-field is empty.

Is this because View::make() actually returns an object? And how to I get the raw html in that case?

  • 写回答

1条回答 默认 最新

  • dtwr2012 2015-04-30 21:50
    关注

    View::make() and view() return a view object. Call render to get the raw HTML string:

    $message = [
        'html' => view('emails.wishlist.share', [
            'name' => auth()->user()->fName, 
            'list' => $list,
        ])->render(),
    ];
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里