From 65d1fdd3f03702178bea61c4a05f09569acf580d Mon Sep 17 00:00:00 2001 From: Abdulrazzaq Alhendi Date: Fri, 6 Feb 2026 03:59:38 +0300 Subject: [PATCH] feat(mail): add CC and BCC fields to email requests and forms (#466) * feat(mail): add CC and BCC fields to email requests and forms * chore: fmt --- app/Http/Requests/SendEstimatesRequest.php | 6 ++++ app/Http/Requests/SendInvoiceRequest.php | 6 ++++ app/Http/Requests/SendPaymentRequest.php | 6 ++++ app/Mail/SendEstimateMail.php | 2 ++ app/Mail/SendInvoiceMail.php | 2 ++ app/Mail/SendPaymentMail.php | 2 ++ app/Models/Estimate.php | 9 +++++- app/Models/Invoice.php | 9 +++++- app/Models/Payment.php | 9 +++++- lang/en.json | 2 ++ .../modal-components/SendEstimateModal.vue | 32 +++++++++++++++++++ .../modal-components/SendInvoiceModal.vue | 32 +++++++++++++++++++ .../modal-components/SendPaymentModal.vue | 32 +++++++++++++++++++ 13 files changed, 146 insertions(+), 3 deletions(-) diff --git a/app/Http/Requests/SendEstimatesRequest.php b/app/Http/Requests/SendEstimatesRequest.php index 807e5fac..45163e0b 100644 --- a/app/Http/Requests/SendEstimatesRequest.php +++ b/app/Http/Requests/SendEstimatesRequest.php @@ -32,6 +32,12 @@ class SendEstimatesRequest extends FormRequest 'to' => [ 'required', ], + 'cc' => [ + 'nullable', + ], + 'bcc' => [ + 'nullable', + ], ]; } } diff --git a/app/Http/Requests/SendInvoiceRequest.php b/app/Http/Requests/SendInvoiceRequest.php index 758971d6..a5f72a6c 100644 --- a/app/Http/Requests/SendInvoiceRequest.php +++ b/app/Http/Requests/SendInvoiceRequest.php @@ -32,6 +32,12 @@ class SendInvoiceRequest extends FormRequest 'to' => [ 'required', ], + 'cc' => [ + 'nullable', + ], + 'bcc' => [ + 'nullable', + ], ]; } } diff --git a/app/Http/Requests/SendPaymentRequest.php b/app/Http/Requests/SendPaymentRequest.php index d020bcfa..5864be71 100644 --- a/app/Http/Requests/SendPaymentRequest.php +++ b/app/Http/Requests/SendPaymentRequest.php @@ -32,6 +32,12 @@ class SendPaymentRequest extends FormRequest 'to' => [ 'required', ], + 'cc' => [ + 'nullable', + ], + 'bcc' => [ + 'nullable', + ], ]; } } diff --git a/app/Mail/SendEstimateMail.php b/app/Mail/SendEstimateMail.php index 2ceb3e7f..70b5ea37 100644 --- a/app/Mail/SendEstimateMail.php +++ b/app/Mail/SendEstimateMail.php @@ -36,6 +36,8 @@ class SendEstimateMail extends Mailable $log = EmailLog::create([ 'from' => $this->data['from'], 'to' => $this->data['to'], + 'cc' => $this->data['cc'] ?? null, + 'bcc' => $this->data['bcc'] ?? null, 'subject' => $this->data['subject'], 'body' => $this->data['body'], 'mailable_type' => Estimate::class, diff --git a/app/Mail/SendInvoiceMail.php b/app/Mail/SendInvoiceMail.php index 8d19b037..fa731ffc 100644 --- a/app/Mail/SendInvoiceMail.php +++ b/app/Mail/SendInvoiceMail.php @@ -36,6 +36,8 @@ class SendInvoiceMail extends Mailable $log = EmailLog::create([ 'from' => $this->data['from'], 'to' => $this->data['to'], + 'cc' => $this->data['cc'] ?? null, + 'bcc' => $this->data['bcc'] ?? null, 'subject' => $this->data['subject'], 'body' => $this->data['body'], 'mailable_type' => Invoice::class, diff --git a/app/Mail/SendPaymentMail.php b/app/Mail/SendPaymentMail.php index 82417b45..79003341 100644 --- a/app/Mail/SendPaymentMail.php +++ b/app/Mail/SendPaymentMail.php @@ -36,6 +36,8 @@ class SendPaymentMail extends Mailable $log = EmailLog::create([ 'from' => $this->data['from'], 'to' => $this->data['to'], + 'cc' => $this->data['cc'] ?? null, + 'bcc' => $this->data['bcc'] ?? null, 'subject' => $this->data['subject'], 'body' => $this->data['body'], 'mailable_type' => Payment::class, diff --git a/app/Models/Estimate.php b/app/Models/Estimate.php index 6d4d4c31..8ba0bd5c 100644 --- a/app/Models/Estimate.php +++ b/app/Models/Estimate.php @@ -374,7 +374,14 @@ class Estimate extends Model implements HasMedia $this->save(); } - \Mail::to($data['to'])->send(new SendEstimateMail($data)); + $mail = \Mail::to($data['to']); + if (! empty($data['cc'])) { + $mail->cc($data['cc']); + } + if (! empty($data['bcc'])) { + $mail->bcc($data['bcc']); + } + $mail->send(new SendEstimateMail($data)); return [ 'success' => true, diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index ae24c30a..5c923af7 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -464,7 +464,14 @@ class Invoice extends Model implements HasMedia { $data = $this->sendInvoiceData($data); - \Mail::to($data['to'])->send(new SendInvoiceMail($data)); + $mail = \Mail::to($data['to']); + if (! empty($data['cc'])) { + $mail->cc($data['cc']); + } + if (! empty($data['bcc'])) { + $mail->bcc($data['bcc']); + } + $mail->send(new SendInvoiceMail($data)); if ($this->status == Invoice::STATUS_DRAFT) { $this->status = Invoice::STATUS_SENT; diff --git a/app/Models/Payment.php b/app/Models/Payment.php index 763a880b..81734137 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -144,7 +144,14 @@ class Payment extends Model implements HasMedia { $data = $this->sendPaymentData($data); - \Mail::to($data['to'])->send(new SendPaymentMail($data)); + $mail = \Mail::to($data['to']); + if (! empty($data['cc'])) { + $mail->cc($data['cc']); + } + if (! empty($data['bcc'])) { + $mail->bcc($data['bcc']); + } + $mail->send(new SendPaymentMail($data)); return [ 'success' => true, diff --git a/lang/en.json b/lang/en.json index fa1a523d..d051100a 100644 --- a/lang/en.json +++ b/lang/en.json @@ -29,6 +29,8 @@ "to_date": "To Date", "from": "From", "to": "To", + "cc": "CC", + "bcc": "BCC", "ok": "Ok", "yes": "Yes", "no": "No", diff --git a/resources/scripts/admin/components/modal-components/SendEstimateModal.vue b/resources/scripts/admin/components/modal-components/SendEstimateModal.vue index a45a204f..36ea3bfe 100644 --- a/resources/scripts/admin/components/modal-components/SendEstimateModal.vue +++ b/resources/scripts/admin/components/modal-components/SendEstimateModal.vue @@ -42,6 +42,30 @@ @input="v$.to.$touch()" /> + + + + + + + + + + + + + + + + + +