payment->load('company', 'client.contacts', 'invoices'); if (!$this->contact) { $this->contact = $this->payment->client->contacts()->first(); } // $this->payment->invoices->sortByDesc('id')->first(function ($invoice) { // $invoice->invitations->each(function ($invitation) { // if (!$invitation->contact->trashed() && $invitation->contact->email) { EmailPayment::dispatch($this->payment, $this->payment->company, $this->contact); event(new PaymentWasEmailed($this->payment, $this->payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); // } // }); // }); } }