From ff8aa8b5361b68123f961bcfbd32ea3b4e1889ce Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Sat, 29 Nov 2025 17:54:12 +0530 Subject: [PATCH] Update startDate logic in InvoiceDataMail content method to handle null document_date --- app/Mail/InvoiceDataMail.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Mail/InvoiceDataMail.php b/app/Mail/InvoiceDataMail.php index 764d7fa..4fc64d7 100644 --- a/app/Mail/InvoiceDataMail.php +++ b/app/Mail/InvoiceDataMail.php @@ -51,9 +51,12 @@ class InvoiceDataMail extends Mailable $firstRecord = InvoiceDataValidation::orderBy('document_date', 'asc')->first(); // $lastRecord = InvoiceDataValidation::orderBy('document_date', 'desc')->first(); - if ($firstRecord) { + $startDate = null; + if ($firstRecord && $firstRecord->document_date != null && $firstRecord->document_date != '') { $startDate = \Carbon\Carbon::parse($firstRecord->document_date)->startOfDay(); // $endDate = \Carbon\Carbon::parse($lastRecord->document_date)->endOfDay(); + } else { + $startDate = now()->subDay()->setTime(10, 0, 0); } $endDate = now()->setTime(10, 0, 0);