invoice = $invoice; $this->reminder_template = $reminder_template; } /** * Execute the job. * * * @return void */ public function handle() { //only the reminder should mark the reminder sent field $this->invoice->service()->markSent()->save(); $this->invoice->invitations->load('contact.client.country', 'invoice.client.country', 'invoice.company')->each(function ($invitation) { EmailEntity::dispatch($invitation, $this->invoice->company, $this->reminder_template)->delay(now()->addSeconds(5)); }); if ($this->invoice->invitations->count() >= 1) { $this->invoice->entityEmailEvent($this->invoice->invitations->first(), 'invoice', $this->reminder_template); } } }