1

我已经在邮件中分配了公共变量。我得到了一些键值,但我从后来分配的键中得到了空值。我也在实现队列。

在我的控制器中:

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}}为什么?

4

1 回答 1

0

如果您不想将 $order 作为 Order Model 的实例传递,则可以将带有 order 的刀片作为变量传递。

这将属于您的构建方法

public function build() { return $this->view('emails.ecommerce.cancel_refund_order_mail')->with([ 'order' => $this->order, 'order_type' => $this->order_type]); }

于 2019-01-03T06:15:18.877 回答