I need to send confirmation emails on a checkout page. But with the current way I only pass $checkout
.
This is the database structure of what data I need to pass:
this is how the $checkout
gets passed to the Mailable
// send confirmation email to customer
Mail::to($request->email)->send(new CheckoutConfirmation($checkout));
Mailable:
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use App\Models\Events;
class CheckoutConfirmation extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($checkout)
{
$this->checkout = $checkout;
// get the course data from the database
$event = Events::query()
->where('id', '=', $this->checkout->event_id)
->first();
// this needs to be passed, along $checkout
// $event->title;
// $event->start;
// $event->end;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->view('emails.checkout.customer')->subject('Wir freuen uns schon auf Sie! Hier ist die Bestätigung Ihrer Buchung.')->with('checkout', $this->checkout);
}
}
the issue with how it is currently handeled is that I can only call:
$checkout->xxx
but I also need to call $event->xxx
in the email blade.