Added trigger approval mail pages
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Failing after 18s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 11s
Laravel Pint / pint (pull_request) Successful in 6m33s
Laravel Larastan / larastan (pull_request) Failing after 6m51s
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Failing after 18s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 11s
Laravel Pint / pint (pull_request) Successful in 6m33s
Laravel Larastan / larastan (pull_request) Failing after 6m51s
This commit is contained in:
115
app/Mail/CharacteristicApprovalMail.php
Normal file
115
app/Mail/CharacteristicApprovalMail.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?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\Support\Facades\URL;
|
||||
use Illuminate\Mail\Mailables\Attachment;
|
||||
use Storage;
|
||||
|
||||
class CharacteristicApprovalMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $request;
|
||||
public $approverName;
|
||||
public $level;
|
||||
|
||||
public $pdfPath;
|
||||
public $tableData;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($request, $approverName, $level, $pdfPath = null, $characteristics = [])
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->approverName = $approverName;
|
||||
$this->level = $level;
|
||||
$this->pdfPath = $pdfPath;
|
||||
$this->tableData = $characteristics;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Characteristic Approval Mail',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'mail.characteristic-approval',
|
||||
with: [
|
||||
'company' => 'CRI Digital Manufacturing Solutions',
|
||||
'greeting' => 'Dear ' . $this->approverName . ',',
|
||||
'request' => $this->request,
|
||||
'tableData' => $this->tableData,
|
||||
'approveUrl' => $this->approveUrl(),
|
||||
'holdUrl' => $this->holdUrl(),
|
||||
'rejectUrl' => $this->rejectUrl(),
|
||||
'wishes' => 'Thanks & Regards,<br>CRI Digital Manufacturing Solutions',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
protected function approveUrl()
|
||||
{
|
||||
return URL::signedRoute('characteristic.approve', [
|
||||
'id' => $this->request->id,
|
||||
'level' => $this->level
|
||||
]);
|
||||
}
|
||||
|
||||
protected function holdUrl()
|
||||
{
|
||||
return URL::signedRoute('characteristic.hold', [
|
||||
'id' => $this->request->id,
|
||||
'level' => $this->level
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
protected function rejectUrl()
|
||||
{
|
||||
return URL::signedRoute('characteristic.reject', [
|
||||
'id' => $this->request->id,
|
||||
'level' => $this->level
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
if (! $this->pdfPath) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (! Storage::disk('local')->exists($this->pdfPath)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
Attachment::fromStorageDisk(
|
||||
'local',
|
||||
$this->pdfPath
|
||||
)->as(basename($this->pdfPath)),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user