diff --git a/app/Ninja/Mailers/UserMailer.php b/app/Ninja/Mailers/UserMailer.php index afa42f9f5596..6f09c20d9f5a 100644 --- a/app/Ninja/Mailers/UserMailer.php +++ b/app/Ninja/Mailers/UserMailer.php @@ -36,10 +36,10 @@ class UserMailer extends Mailer public function sendNotification(User $user, Invoice $invoice, $notificationType, Payment $payment = null) { - if (!$user->email) { + if (! $user->email || $user->cannot('view', $invoice)) { return; } - + $entityType = $invoice->getEntityType(); $view = ($notificationType == 'approved' ? ENTITY_QUOTE : ENTITY_INVOICE) . "_{$notificationType}"; $account = $user->account; @@ -65,7 +65,7 @@ class UserMailer extends Mailer 'invoice' => $invoice->invoice_number, 'client' => $client->getDisplayName() ]); - + $this->sendTo($user->email, CONTACT_EMAIL, CONTACT_NAME, $subject, $view, $data); } @@ -89,7 +89,7 @@ class UserMailer extends Mailer 'contactName' => $invitation->contact->getDisplayName(), 'invoiceNumber' => $invoice->invoice_number, ]; - + $this->sendTo($user->email, CONTACT_EMAIL, CONTACT_NAME, $subject, $view, $data); } } diff --git a/database/seeds/UserTableSeeder.php b/database/seeds/UserTableSeeder.php index 1fe962276c93..62d6be1016d4 100644 --- a/database/seeds/UserTableSeeder.php +++ b/database/seeds/UserTableSeeder.php @@ -42,6 +42,7 @@ class UserTableSeeder extends Seeder 'primary_color' => $faker->hexcolor, 'timezone_id' => 1, 'company_id' => $company->id, + 'is_admin' => 1, ]); $user = User::create([