mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 12:33:56 +00:00
84 lines
2.6 KiB
PHP
84 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Notifications;
|
|
|
|
use App\Models\Booking;
|
|
use App\Models\User;
|
|
use App\Models\File;
|
|
use App\Models\UserEmailVerification;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
class PaymentProofUploadedEmail extends AbstractEmail
|
|
{
|
|
|
|
/** @var User */
|
|
private $user;
|
|
|
|
/** @var Booking */
|
|
private $booking;
|
|
|
|
/** @var File */
|
|
private $file;
|
|
|
|
/**
|
|
* UserVerificationEmail constructor.
|
|
* @param User $user
|
|
* @param UserEmailVerification $attempt
|
|
*/
|
|
public function __construct(User $user, Booking $booking, File $file)
|
|
{
|
|
$this->user = $user;
|
|
$this->booking = $booking;
|
|
$this->file = $file;
|
|
}
|
|
|
|
|
|
public function toMail()
|
|
{
|
|
$mailMessage = (new MailMessage)->subject('Transfer Completed (REF: ' . $this->booking->marking . ')');
|
|
|
|
// STEP 1: Get file to be attached to email
|
|
// $attachedFile = null;
|
|
// $file_path = '';
|
|
// $file_info = $this->file->getFileAttribute($this->file)->file->file_info;
|
|
// foreach ($file_info as $fileCount => $fileVal) {
|
|
// if (isset($fileVal->original)) {
|
|
// $file_path = $fileVal->original->file;
|
|
// //$attachedFile = storage_path('app/documents/' . $file_path);
|
|
// }
|
|
// }
|
|
|
|
// STEP 2: Check whether to fetch from S3 bucket or local storage
|
|
// if($file_path){
|
|
// $filesystemDriver = Storage::getDefaultDriver();
|
|
// if($filesystemDriver === 's3'){
|
|
// $fileContent = null;
|
|
// $fileContent = Storage::disk('s3')->get($file_path);
|
|
// if ($fileContent) {
|
|
// $mailMessage->attachData($fileContent, 'invoice.pdf', [
|
|
// 'mime' => 'application/pdf',
|
|
// ]);
|
|
// }
|
|
// }
|
|
// else{
|
|
// $filePath = '';
|
|
// // $fileContent = Storage::disk('documents')->get($invoiceDocument->first()->file->file_info->original->file);
|
|
// $filePath = storage_path('app/documents/' . $file_path);
|
|
// if ($filePath) {
|
|
// $mailMessage->attach($filePath, [
|
|
// 'as' => 'invoice.pdf',
|
|
// 'mime' => 'application/pdf',
|
|
// ]);
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
$mailMessage->view('emails.accounts.payment_proof_email', ['user' => $this->user, 'booking' => $this->booking]);
|
|
|
|
return $mailMessage;
|
|
}
|
|
|
|
|
|
}
|