I'm trying to put send an email using mailables and jobs.
However for some reason the attachments and the body is duplicated
Job:
class SendReservationConfirmed implements ShouldQueue
{
protected $subscriber;
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public function __construct(Subscriber $subscriber)
{
$this->subscriber = $subscriber;
}
public function handle()
{
$email = new ReservationConfirmed($this->subscriber);
Mail::to($this->subscriber->email)->send($email);
}
}
Mailable:
class ReservationConfirmed extends Mailable
{
use Queueable, SerializesModels;
public $subscriber;
public function __construct(Subscriber $subscriber)
{
$this->subscriber = $subscriber;
}
public function build()
{
$attachments = [];
$email = $this->view('emails.confirm-new')
->with(['subscriber' => $this->subscriber]);
The job only get's executed once, the model i'm dispatching has the following data:
"data": {
"id": 119,
"first_name": "",
"reservations": [
{
"spot_id": 686,
"spot": {
"id": 686,
"zone": {
"id": 125,
"number": 123,
"name": "",
}
}
},
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire