Enhance InvoiceDataMail to accept a dynamic subject and update SendInvoiceDataReport command accordingly

This commit is contained in:
dhanabalan
2025-11-11 09:32:46 +05:30
parent 26ad8b2ed8
commit 9eaf86d347
3 changed files with 14 additions and 8 deletions

View File

@@ -201,7 +201,9 @@ class SendInvoiceDataReport extends Command
}) })
->toArray(); ->toArray();
$mail = new InvoiceDataMail($scheduleType, $tableData); $mailSubject = "Invoice Data Report ({$plant->name})";
$mail = new InvoiceDataMail($scheduleType, $tableData, $mailSubject);
$contentVars = $mail->content()->with; $contentVars = $mail->content()->with;
$this->info($contentVars['greeting'] ?? 'Invoice Data Report'); $this->info($contentVars['greeting'] ?? 'Invoice Data Report');

View File

@@ -14,16 +14,20 @@ class InvoiceDataMail extends Mailable
{ {
use Queueable, SerializesModels; use Queueable, SerializesModels;
public $tableData;
public $scheduleType; public $scheduleType;
public $tableData;
public $mailSubject;
/** /**
* Create a new message instance. * Create a new message instance.
*/ */
public function __construct($scheduleType,$tableData = []) public function __construct($scheduleType, $tableData = [], $mailSubject)
{ {
$this->scheduleType = $scheduleType; $this->scheduleType = $scheduleType;
$this->tableData = $tableData ?? []; $this->tableData = $tableData ?? [];
$this->mailSubject = $mailSubject ?? 'Invoice Data Report';
} }
/** /**
@@ -32,7 +36,7 @@ class InvoiceDataMail extends Mailable
public function envelope(): Envelope public function envelope(): Envelope
{ {
return new Envelope( return new Envelope(
subject: 'Invoice Data Report', subject: $this->mailSubject,
); );
} }

View File

@@ -68,8 +68,8 @@
<div style="text-align: center; font-weight: bold;"> <div style="text-align: center; font-weight: bold;">
{{ $company }} {{ $company }}
</div> </div>
<br> <br>
<p>{!! $greeting !!}</p> <p>{!! $greeting !!}</p>
<div class="container"> <div class="container">
@if(empty($tableData)) @if(empty($tableData))
<p style="text-align:center;">No invoice data available for this schedule.</p> <p style="text-align:center;">No invoice data available for this schedule.</p>