我在控制器中的编码:
$order= Order::find($id);
$data = array(
'name' => $order->customer->name,
'email' => $order->customer->email,
'no_tel' => $order->customer->no_tel,
'date' => Carbon::now('Asia/Kuala_Lumpur'),
);
Mail::send('emails.invoice1', $data, function ($message) {
$message->from('admin@mapdip5b.com', 'Sales');
$message->to($data['email'], $data['name'])->subject('Your Payment Has Been Accepted');
});
问题是,如何在Mail :: send方法中传递$数据?
谢谢
答案 0 :(得分:1)
闭包是功能。功能有自己的范围&#34;所以他们看不到范围之外的变量。您可以使用关键字mTracker = analytics.newTracker(<here>)
将$data
导入闭包范围。尝试:
use