1
0
forked from poc/pds

Added import transit excel attachment logic in mail

This commit is contained in:
dhanabalan
2026-06-12 09:20:03 +05:30
parent 3c5f9f7273
commit 05a3c9f7ac
2 changed files with 60 additions and 34 deletions

View File

@@ -9,6 +9,7 @@ use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
use Illuminate\Mail\Mailables\Attachment;
class ImportTransitMail extends Mailable
{
@@ -20,14 +21,17 @@ class ImportTransitMail extends Mailable
public $mailSubject;
public $excelPath;
/**
* Create a new message instance.
*/
public function __construct($scheduleType, $tableData, $mailSubject)
public function __construct($scheduleType, $tableData, $mailSubject, $excelPath)
{
$this->scheduleType = $scheduleType;
$this->tableData = $tableData ?? [];
$this->mailSubject = $mailSubject ?? 'Import Transit';
$this->excelPath = $excelPath;
}
/**
@@ -90,6 +94,14 @@ class ImportTransitMail extends Mailable
*/
public function attachments(): array
{
return [];
return [
Attachment::fromStorageDisk(
'local',
$this->excelPath
)->as('Import_Transit_Report.xlsx')
->withMime(
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
),
];
}
}