简体   繁体   English

Laravel Mailables动态视图视为刀片

[英]Laravel mailables dynamic view treat as blade

does it possible to do: 是否可以做到:

Create Mailable class in my package and use it to Mail::send(new MyMaiable($config)) 在我的程序包中创建Mailable类,并将其用于Mail::send(new MyMaiable($config))

In my config will also html template saved in database. 在我的配置中还将html模板保存在数据库中。

My question is does it any way to use this html string as blade template 我的问题是使用此html字符串作为刀片模板有任何办法吗

I mean {{$var}} will replace without manually str_replace or preg_replace_all but by ->with([]) method. 我的意思是{{$var}}将替换为->with([])方法,而无需手动str_replacepreg_replace_all

Environment 环境

  • php 5.6 的PHP 5.6
  • Laravel 5.4 Laravel 5.4

Thanks in advance for any hints. 预先感谢您的任何提示。

Why are you storing the html template in your database? 为什么将html模板存储在数据库中? Save the template in your resources->emails folder as a blade template and call it in the mailable class like this: 将模板保存在resources-> emails文件夹中作为刀片模板,并在可邮寄类中调用它,如下所示:

public function build()
{
    return $this->from('YOUR_FROM_EMAIL')
        ->view('emails.TEMPLATE_NAME');
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM