diff --git a/app/Ninja/Mailers/ContactMailer.php b/app/Ninja/Mailers/ContactMailer.php index 9e72bd12fe..ba6714285c 100644 --- a/app/Ninja/Mailers/ContactMailer.php +++ b/app/Ninja/Mailers/ContactMailer.php @@ -259,7 +259,7 @@ class ContactMailer extends Mailer $invitation = $payment->invitation; } else { $user = $payment->user; - $contact = $client->contacts[0]; + $contact = count($client->contacts) ? $client->contacts[0] : ''; $invitation = $payment->invoice->invitations[0]; } diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index 1a00104346..fa568f3c85 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -710,6 +710,10 @@ class InvoiceRepository extends BaseRepository $client->load('contacts'); $sendInvoiceIds = []; + if (! count($client->contacts)) { + return $invoice; + } + foreach ($client->contacts as $contact) { if ($contact->send_invoice) { $sendInvoiceIds[] = $contact->id; diff --git a/app/Services/ImportService.php b/app/Services/ImportService.php index f06241c959..478c0f4033 100644 --- a/app/Services/ImportService.php +++ b/app/Services/ImportService.php @@ -868,7 +868,7 @@ class ImportService $this->maps['client'][$name] = $client->id; $this->maps['client_ids'][$client->public_id] = $client->id; } - if ($name = strtolower(trim($client->contacts[0]->email))) { + if (count($client->contacts) && $name = strtolower(trim($client->contacts[0]->email))) { $this->maps['client'][$name] = $client->id; $this->maps['client_ids'][$client->public_id] = $client->id; }