我想在placed.plade.php balde 中顯示訂單的資訊,但它給了我錯誤:Argument 1 passed to App\Mail\OrderPlaced::__construct() must be an instance of App\Mail\ App\Order, null given, called in D:\wamp\www\aswakt\routes\web.php在第77 行,即使我在模型建構式OrderPlaced.php 中傳遞了一個引數。
網頁.php
Route::get('/mailable', function(){
$order = App\Order::find(1);
return new App\Mail\OrderPlaced($order);
});
已下訂單.php
public $order;
public function __construct(Order $order)
{
$this->order = $order;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->to($this->order->billing_email,$this->order->billing_name)
->bcc('[email protected]')
->subject('Order for aswak tinghir ')
->markdown('emails.orders.placed');
}
放置.blade.php
**Order ID:** {{ $order->id }}
**Order Email:** {{ $order->billing_email }}
**Order Name:** {{ $order->billing_name }}
**Order Total:** ${{ round($order->billing_total / 100, 2) }}
uj5u.com熱心網友回復:
錯誤是因為$order您傳遞的引數return new App\Mail\OrderPlaced($order);為空。這是因為id = 1在您的orders表中沒有找到訂單。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/334800.html
上一篇:如何將TXT檔案寫入“/storage/emulated/0/myapp/myfile.txt”,以便稍后從檔案瀏覽器打開它們?
