laravel - 使用邮件 laravel 发送生成的二维码
问题描述
大家好,我有一个生成二维码并将其发送到用户的电子邮件的方法,但是二维码 $text 没有显示在电子邮件中,我不知道为什么?
我制作 DD($text) 时的二维码;
Illuminate\Support\HtmlString {#1324 ▼
#html: """
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="200" height="200" viewBox="0 0 200 200"><rect x="0" y="0" width="200" height="200" fill="#ffffff"/> ▶
"""
}
这是控制器方法:
public static function sendQrcode($id_locateur)
{
$locateur = Locateur::findOrFail($id_locateur);
$info_loc = DB::table('locateurs')
->join('confirm_logments', 'confirm_logments.id_Locateur', '=', 'locateurs.id')
->join('appartements', 'appartements.id', '=', 'confirm_logments.id_Appartement')
->where("locateurs.id", "=", $id_locateur)
->get(["locateurs.nom", "locateurs.prenom", "locateurs.Nbr_Invite", "confirm_logments.DateD", "confirm_logments.DateF", "appartements.nom as nomAppartement"])
->first();
setlocale(LC_TIME, 'French');
$datedebut = Carbon::parse($info_loc->DateD)->formatLocalized('%d %B %Y');
$datefin = Carbon::parse($info_loc->DateF)->formatLocalized('%d %B %Y');
$text = (new Generator())->size(200)->generate("Le locateur $info_loc->nom $info_loc->prenom \n(accompagné de ses $info_loc->Nbr_Invite compagnons) \na effectivement loué l'appartement : $info_loc->nomAppartement \nentre le " . $datedebut . " et le " . utf8_encode($datefin));
Mail::to($locateur->email)->send(new QR($text));
return view("emails/QR")
->with('text', $text);
}
这是我的 QR.php 课程
class QR extends Mailable
{
use Queueable, SerializesModels;
public $text;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($text)
{
$this->text = $text;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
// dd($this->text);
return $this->view('emails.QR');
}
}
这是我想在电子邮件中显示的视图
<div class="card">
<div class="card-body">
<h1>this is your QR code</h1>
{!! $text !!}}
</div>
</div>
解决方案
推荐阅读
- apache - 你能帮我删除重写规则中的 index.php 吗?
- ios - iOS 中 FileManager 的内容在哪里?
- javascript - 我的 c++ 代码比 javascript 代码慢很多
- reactjs - 在 React 中下载 excel 文件大小的问题
- reactjs - 设置 CSS 后如何立即运行函数?
- drupal-7 - Drupal 7 上没有存储用户配置文件的图像
- assembly - 为什么在这种情况下使用 IMUL r/m8 指令时设置 OF 和 CF 标志
- python - 如何将社交图书搜索 XML 集合转换为 TREC 集合?
- node.js - webpack 在编译时内存不足
- c# - .Net Core Firebase 使用 JWT 的 Google 电子邮件身份验证 - 401