I want to send the give of an order and also of product(annonce) to Mailtrap, I tried by order whose id = 1 as a test, when sending, everything works fine, just give them of product(annonce) not displayed in Mailtrap, on the other hand giving them an order is displayed well. I don't know exactly where the problem is. and why the product(annonce) information is not showing.
web.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'];
}
Order.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');
}
placed.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