我想将订单和产品(annonce)发送到Mailtrap,我尝试了id = 1的订单作为测试,发送时一切正常,只需给他们未显示在Mailtrap中的产品(annonce) ,另一方面,给他们下订单会很好地显示出来。我不知道问题出在哪里。以及为什么没有显示产品(公告)信息。
网页.php
Route::get('/mailable', function(){
$order = App\Order::find(1);
//dd($order);
return new App\Mail\OrderPlaced($order);
});
OrderAnnonce.php
class OrderAnnonce extends Model
{
protected $table = 'order_annonce';
protected $fillable = ['order_id','annonce_id','quantity'];
}
订单.php
class Order extends Model
{
protected $fillable = [
'user_id', 'billing_email', 'billing_name', 'billing_address', 'billing_city',
'billing_province', 'billing_postalcode', 'billing_phone', 'billing_name_on_card', 'billing_discount',
'billing_discount_code', 'billing_subtotal', 'billing_tax', 'billing_total', 'payment_gateway',
'error',
];
public function user()
{
return $this->belongsTo('App\User');
}
public function annonces()
{
return $this->belongsToMany('App\Annonce')->withPivot('quantity');
}
放置.blade.php
Thank you for your order.
**Order ID:** {{ $order->id }}
**Order Email:** {{ $order->billing_email }}
**Order Name:** {{ $order->billing_name }}
**Order Total:** ${{ round($order->billing_total / 100, 2) }}
**Items Ordered**
@foreach($order->annonces as $annonce)
Name: {{ $annonce->name }} <br>
Price: ${{ round($annonce->price / 100, 2)}} <br>
Quantity: {{ $annonce->pivot->quantity }} <br>
@endforeach