[英]passing multiple data to email view laravel 5.3
I have checked some questions about this question but still couldn't figure out. 我已经检查了有关此问题的一些问题,但仍然无法弄清楚。
So here is my controller ( I cut off some code to make the question short) : 所以这是我的控制器(我切断了一些代码以简化问题):
public function hour(Request $request)
{
$user = JWTAuth::parseToken()->authenticate();
$user->phone = $request->phone;
$user->city = $request->city;
$user->street = $request->street;
$user->save();
$car = Car::find($request->id);
$car->status = 'yes';
$car->save();
$time = new Reservation();
$time->from_date = $from;
$time->to_date = $to;
$Reservation_id = $time->id;
$time->save();
Mail::to('email@gmail.com')->send(new NewRequestMail($user,$car,$time));
then in Mailable: 然后在Mailable中:
public $car;
public $user;
public $time;
public function __construct($car,$time,$user)
{
$this->car = $car;
$this->time = $time;
$this->user = $user;
}
Now when I try to fetch data in email.view liek this $car->status
or try to get more info about the user $user->street
I get blank in my email! 现在,当我尝试在email.view中获取数据时,会出现此
$car->status
car- $car->status
或者尝试获取有关用户$user->street
更多信息,我的电子邮件中为空白! the only thing I get is the $user->name
. 我唯一得到的是
$user->name
。 Is there a better way to do this ? 有一个更好的方法吗 ? you help will be really appreciated
您的帮助将不胜感激
please use laravel mail function with params 请使用带有参数的laravel邮件功能
use Mail;
$to = '';
$from = '';
$subject = '';
Mail::send('email.enquiry', compact('user','car','time'), function ($message) use ($to,$from,$subject) {
$message->from($from)
->to($to)
->subject($subject);
});
So in enquiry.blade.php(inside email folder) file you can access the object properties 因此,在enquiry.blade.php(内部电子邮件文件夹)文件中,您可以访问对象属性
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.