company = $company; $this->user = $user; $this->invitation = $invitation; $this->entity = $invitation->{$entity_type}; $this->entity_type = $entity_type; $this->settings = $invitation->contact->client->getMergedSettings(); } /** * Execute the job. * * @return void */ public function handle() { //Set DB MultiDB::setDb($this->company->db); //if we need to set an email driver do it now $this->setMailDriver(); $mail_obj = (new EntityViewedObject($this->invitation, $this->entity_type))->build(); $mail_obj->from = [$this->entity->user->email, $this->entity->user->present()->name()]; //send email Mail::to($this->user->email) ->send(new EntityNotificationMailer($mail_obj)); //catch errors if (count(Mail::failures()) > 0) { return $this->logMailError(Mail::failures(), $this->invoice->client); } } }