69 lines
2.1 KiB
PHP
69 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Core\Mail;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\Facades\Config;
|
|
|
|
class NewBookingMail extends Mailable
|
|
{
|
|
|
|
use Queueable, SerializesModels;
|
|
|
|
public $tries = 5;
|
|
public $timeout = 30;
|
|
|
|
protected $param;
|
|
|
|
|
|
public function __construct($param)
|
|
{
|
|
$this->param = $param;
|
|
}
|
|
|
|
public function build()
|
|
{
|
|
try {
|
|
$params = $this->param;
|
|
$mailParams = $params['mailViewParams'];
|
|
|
|
$mailData = $params['mailData'];
|
|
$mailSenderAddress = Config::get('app.mailSenderAddress');
|
|
app('translator')->setLocale($mailParams["language_code"]);
|
|
|
|
$bookingData = __('api-mailling-booking-desc', [
|
|
'booking_code' => $mailParams['booking_code'],
|
|
'property_name' => $mailParams['property_name'],
|
|
'checkin_date' => $mailParams['checkin_date'],
|
|
'checkout_date' => $mailParams['checkout_date']
|
|
]);
|
|
|
|
$mailSubject = __('api-malling-booking-new_booking_info-title');
|
|
if (isset($mailParams['bookingChannelCategoryId']) && $mailParams['bookingChannelCategoryId'] != 3) {
|
|
$mailSubject = $mailParams['bookingChannelName'] . ' - ' . $mailSubject;
|
|
}
|
|
|
|
/*echo view('emails.newBookingMail', compact('mailParams', 'bookingData'));
|
|
die();*/
|
|
|
|
return $this->from($mailSenderAddress, 'Extranetwork - ' . $mailParams['property_name'])
|
|
->view('emails.newBookingMail', compact('mailParams', 'bookingData'))
|
|
->to($mailData['to']["email"], $mailData['to']["name"])
|
|
->bcc($mailData['bcc'])
|
|
->subject('🛎️ '.$mailSubject)
|
|
->with(['message' => $this]);
|
|
|
|
|
|
} catch (Exception $e) {
|
|
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
|
Log::error($message);
|
|
return output(['status' => -1, 'message' => $e->getMessage()]);
|
|
}
|
|
}
|
|
|
|
}
|