From d1e58ec94cebe93e04112f024b2f6ba12118f0fe Mon Sep 17 00:00:00 2001 From: Nadir Hamid Date: Mon, 1 Jun 2026 22:29:17 +0000 Subject: [PATCH] log errors when attaching invoices to emails --- app/app/Helpers/WorkspaceInvoiceHelper.php | 37 ++++++++++++---------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/app/app/Helpers/WorkspaceInvoiceHelper.php b/app/app/Helpers/WorkspaceInvoiceHelper.php index 7b7beb78a..4013a236a 100644 --- a/app/app/Helpers/WorkspaceInvoiceHelper.php +++ b/app/app/Helpers/WorkspaceInvoiceHelper.php @@ -63,22 +63,27 @@ public static function sendInvoiceForWorkspace(Workspace $workspace, $period, Us $filePrefix = 'monthly'; } - Mail::send('emails.workspace_invoices', [ - 'user' => $owner, - 'workspace' => $workspace, - 'site' => $siteName, - 'site_name' => $siteName, - 'customizations' => $customizations, - 'period' => $period - ], function ($message) use ($owner, $mailConfig, $subject, $pdf, $invoice, $filePrefix) { - $message->to($owner->email); - $message->subject($subject); - $from = $mailConfig['from']; - $message->from($from['address'], $from['name']); - $message->attachData($pdf, sprintf('%s_invoice_%s.pdf', $filePrefix, $invoice->invoice_no), [ - 'mime' => 'application/pdf' - ]); - }); + try { + Mail::send('emails.workspace_invoices', [ + 'user' => $owner, + 'workspace' => $workspace, + 'site' => $siteName, + 'site_name' => $siteName, + 'customizations' => $customizations, + 'period' => $period + ], function ($message) use ($owner, $mailConfig, $subject, $pdf, $invoice, $filePrefix) { + $message->to($owner->email); + $message->subject($subject); + $from = $mailConfig['from']; + $message->from($from['address'], $from['name']); + $message->attachData($pdf, sprintf('%s_invoice_%s.pdf', $filePrefix, $invoice->invoice_no), [ + 'mime' => 'application/pdf' + ]); + }); + } catch (\Exception $e) { + \Log::error('Failed to send invoice email for workspace #' . $workspace->id . ': ' . $e->getMessage()); + throw $e; + } return [ 'workspace_id' => $workspace->id,