credit = $credit; $this->reminder_template = $reminder_template; $this->contact = $contact; } /** * Builds the correct template to send. * @return void */ public function run() { if (! $this->reminder_template) { $this->reminder_template = $this->credit->calculateTemplate('credit'); } $this->credit->invitations->each(function ($invitation) { if (!$invitation->contact->trashed() && $invitation->contact->email) { $email_builder = (new CreditEmail())->build($invitation, $this->reminder_template); // EmailCredit::dispatchNow($email_builder, $invitation, $invitation->company); EmailEntity::dispatchNow($invitation, $invitation->company, $this->reminder_template); } }); $this->credit->service()->markSent(); } }