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 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64
  • ¥15 iOS 自定义输入法-第三方输入法
  • ¥15 很想要一个很好的答案或提示
  • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr
  • ¥15 怀疑手机被监控,请问怎么解决和防止
  • ¥15 Qt下使用tcp获取数据的详细操作
  • ¥15 idea右下角设置编码是灰色的