From 9baf0161c7b42b518730d0f7c0623ec9e9b84246 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 12 Sep 2023 14:51:35 +0200 Subject: [PATCH] fix: help should send cc on email --- app/Http/Livewire/Help.php | 2 +- bootstrap/helpers/shared.php | 30 +++++++++++++------ .../components/navbar-subscription.blade.php | 12 ++++++++ 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/app/Http/Livewire/Help.php b/app/Http/Livewire/Help.php index 505224d2c..acfdc5c58 100644 --- a/app/Http/Livewire/Help.php +++ b/app/Http/Livewire/Help.php @@ -41,7 +41,7 @@ class Help extends Component ] ); $mail->subject("[HELP - {$subscriptionType}]: {$this->subject}"); - send_user_an_email($mail, 'hi@coollabs.io'); + send_user_an_email($mail, 'hi@coollabs.io', auth()->user()?->email); $this->emit('success', 'Your message has been sent successfully. We will get in touch with you as soon as possible.'); } catch (\Throwable $e) { return general_error_handler($e, $this); diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index edb54ab64..f42ac83d7 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -262,21 +262,33 @@ function send_internal_notification(string $message): void ray($e->getMessage()); } } -function send_user_an_email(MailMessage $mail, string $email): void +function send_user_an_email(MailMessage $mail, string $email, ?string $cc = null): void { $settings = InstanceSettings::get(); $type = set_transanctional_email_settings($settings); if (!$type) { throw new Exception('No email settings found.'); } - Mail::send( - [], - [], - fn (Message $message) => $message - ->to($email) - ->subject($mail->subject) - ->html((string) $mail->render()) - ); + if ($cc) { + Mail::send( + [], + [], + fn (Message $message) => $message + ->to($email) + ->cc($cc) + ->subject($mail->subject) + ->html((string) $mail->render()) + ); + } else { + Mail::send( + [], + [], + fn (Message $message) => $message + ->to($email) + ->subject($mail->subject) + ->html((string) $mail->render()) + ); + } } function isEmailEnabled($notifiable) { diff --git a/resources/views/components/navbar-subscription.blade.php b/resources/views/components/navbar-subscription.blade.php index 73e67410b..3770a2d31 100644 --- a/resources/views/components/navbar-subscription.blade.php +++ b/resources/views/components/navbar-subscription.blade.php @@ -10,6 +10,18 @@ +
  • +
    + + + + + + +
    +
  • @csrf