Merge branch 'send-email-payment-proof' of gitlab.com:CIEFWorldwideSdnBhd/exchange-2.0 into development

This commit is contained in:
edmondlang
2023-06-03 17:01:35 +08:00
4 changed files with 25 additions and 43 deletions
@@ -5,6 +5,7 @@ namespace App\Classes\Jobs;
use App\Classes\Notifications\PaymentProofUploadedEmail;
use App\Models\Booking;
use App\Models\User;
use App\Models\File;
use App\Models\UserEmailVerification;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
@@ -23,20 +24,24 @@ class SendUserPaymentProofUploadedEmail implements ShouldQueue
/** @var Booking */
private $booking;
/** @var File */
private $file;
/**
* SendUserVerificationEmail constructor.
* @param User $user
* @param UserEmailVerification $attempt
*/
public function __construct(User $user, Booking $booking)
public function __construct(User $user, Booking $booking, File $file)
{
$this->user = $user;
$this->booking = $booking;
$this->file = $file;
}
public function handle()
{
$this->user->notify(new PaymentProofUploadedEmail($this->user, $this->booking));
$this->user->notify(new PaymentProofUploadedEmail($this->user, $this->booking, $this->file));
}
}
@@ -87,7 +87,7 @@ class CreatePaymentProofDocumentLogic extends AbstractControllerLogic
/** @var Document $document */
$document = $this->createsDocument->execute($transaction, $object);
$this->createsFile->execute($document, $object);
$file = $this->createsFile->execute($document, $object);
$this->updatesTransactionStatus->execute($transaction, ApprovalStatus::APPROVED);
@@ -98,7 +98,7 @@ class CreatePaymentProofDocumentLogic extends AbstractControllerLogic
// todo: a function to send a proof to the receipiant, they have to give us a email of the receipiant and also need to submiited purchase order
$companyEmployee = $transaction->owner->booking->company->employees;
foreach ($companyEmployee as $employee) {
$this->sendUserPaymentProofUploadedEmail::dispatch($employee, $transaction->owner->booking);
$this->sendUserPaymentProofUploadedEmail::dispatch($employee, $transaction->owner->booking, $file[0]);
}
return $this->response([]);
@@ -4,6 +4,7 @@ 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;
@@ -16,24 +17,36 @@ class PaymentProofUploadedEmail extends AbstractEmail
/** @var Booking */
private $booking;
/** @var File */
private $file;
/**
* UserVerificationEmail constructor.
* @param User $user
* @param UserEmailVerification $attempt
*/
public function __construct(User $user, Booking $booking)
public function __construct(User $user, Booking $booking, File $file)
{
$this->user = $user;
$this->booking = $booking;
$this->file = $file;
}
public function toMail()
{
$attachedFile = null;
$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);
}
}
return (new MailMessage)
->subject('Transfer Completed (REF: ' . $this->booking->marking . ')')
// ->to('edmond.wuiming2021@gmail.com') // testing email
// ->attach('/path/to/file') // todo-new: add attachement
->attach($attachedFile) // todo-new: add attachement
->view('emails.accounts.payment_proof_email', ['user' => $this->user, 'booking' => $this->booking]);
}
-36
View File
@@ -618,39 +618,3 @@ Route::get('/po/outsource/check', function(){
Route::get('/upload-honey-trap', function () {
return view('pages.honey_trap');
})->name('upload_honey_trap');
Route::get('/text-transfer-email', function () {
$booking = Booking::where('marking', '25760')->first();
$mployee = $booking->company->employees->first();
return view('emails.accounts.payment_proof_email', ['booking' => $booking, 'user' => $mployee, ]);
});
use Illuminate\Support\Facades\Mail;
Route::get('/show-email', function () {
// Send some emails using MailMessage
// Retrieve the Swift Mailer instance
$mailer = Mail::getSwiftMailer();
// Retrieve the Transport instance
$transport = $mailer->getTransport();
// Retrieve the sent messages
$messages = $transport->getMessages();
// Loop through the sent messages
foreach ($messages as $message) {
// Access the email details
$subject = $message->getSubject();
$from = $message->getFrom();
$to = $message->getTo();
$cc = $message->getCc();
$bcc = $message->getBcc();
// ...and so on
// Output the email details
echo "Subject: $subject\n";
echo "From: $from\n";
echo "To: $to\n";
echo "Cc: $cc\n";
echo "Bcc: $bcc\n";
echo "\n";
}
});