【发布时间】:2018-12-31 10:21:56
【问题描述】:
我已经在邮件中分配了公共变量。我得到了一些键值,但我从后来分配的键中得到了空值。我也在实现队列。
在我的控制器中:
public function changeOrderStatus(Order $order){
$order->type = $request->type; //getting these two keys empty i.e.type and amount
$order->amount = $transaction->amount;
$mail = new CancelRefundOrder($order);
}
在我的 /App/Mail/CancelRefundOrder.php 中
class CancelRefundOrder extends Mailable implements ShouldQueue
{
use Queueable, SerializesModels;
public $order;
public $order_type;
public function __construct($order)
{
$this->order = $order;
$this->order_type = $order->type;
}
public function build()
{
return $this->view('emails.ecommerce.cancel_refund_order_mail');
}
}
如果我在这里dd($order_type) 我得到了价值。但是在我的刀片 cancel_refund_order_mail 中,我在 {{$order_type}} 或 {{$order->type}} 上得到空值,为什么?
【问题讨论】:
-
您是将
$order作为模型传递还是作为属于模型的id 传递?试试public function __construct(Order $order) -
$order 作为模型。
标签: laravel laravel-5 laravel-mail