Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
70 lines
1.6 KiB
PHP
70 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Mail;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Mail\Mailables\Content;
|
|
use Illuminate\Mail\Mailables\Envelope;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Mail\Mailables\Attachment;
|
|
|
|
class DailyTaskReportMail extends Mailable
|
|
{
|
|
use Queueable, SerializesModels;
|
|
|
|
public array $pdfAttachments;
|
|
|
|
public array $rows = [];
|
|
|
|
/**
|
|
* Create a new message instance.
|
|
*/
|
|
public function __construct(array $pdfAttachments, array $rows)
|
|
{
|
|
$this->pdfAttachments = $pdfAttachments;
|
|
$this->rows = $rows;
|
|
}
|
|
/**
|
|
* Get the message envelope.
|
|
*/
|
|
public function envelope(): Envelope
|
|
{
|
|
return new Envelope(
|
|
subject: 'Daily Task Report Mail',
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Get the message content definition.
|
|
*/
|
|
public function content(): Content
|
|
{
|
|
return new Content(
|
|
view: 'mail.daily-task-report',
|
|
with: [
|
|
'rows' => $this->rows,
|
|
],
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Get the attachments for the message.
|
|
*
|
|
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
|
*/
|
|
public function attachments(): array
|
|
{
|
|
return collect($this->pdfAttachments)
|
|
->map(function ($attachment) {
|
|
|
|
return Attachment::fromPath($attachment['path'])
|
|
->as($attachment['name'])
|
|
->withMime('application/pdf');
|
|
|
|
})
|
|
->toArray();
|
|
}
|
|
}
|