87 lines
2.8 KiB
PHP
87 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Core\Mail;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
use Illuminate\Support\Facades\App;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\Facades\Config;
|
|
|
|
class OfferSendMail 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;
|
|
|
|
$propertyService = App::make("App\Core\Service\OfferService");
|
|
|
|
$requestParams = [
|
|
'offer_id' => fillOnUndefined($params, 'offer_id'),
|
|
'property_id' => fillOnUndefined($params, 'property_id'),
|
|
];
|
|
|
|
$offerDetail = $propertyService->findOffer($requestParams);
|
|
$offerDetail = fillOnUndefined($offerDetail, 'data');
|
|
|
|
app('translator')->setLocale($offerDetail["language"]);
|
|
$mailSenderAddress = Config::get('app.mailSenderAddress');
|
|
|
|
$mailParams['to'] = [];
|
|
$mailParams['to'] = $offerDetail['email'];
|
|
|
|
$mailParams['bcc'] = [];
|
|
$mailParams['bcc'][] = Config::get('app.logMailAddress');
|
|
|
|
|
|
$mailParams['property_name'] = $offerDetail['property']['name'];
|
|
$mailParams['url'] = Config::get('app.client_server').'/offer/'.$offerDetail['offer_code'];
|
|
|
|
$mailParams['logo'] = Config::get('app.webUrl').'/assets/img/logo/mini-logo.png';
|
|
if(isset($offerDetail['property_brand']['logoUrl'])) {
|
|
$mailParams['logo'] = $offerDetail['property_brand']['logoUrl'];
|
|
}
|
|
|
|
$description = [];
|
|
$description[] = __('api-mailing-offer_mail-description', ['propertyName' => $offerDetail['property']['name'], 'code' => $offerDetail['ticket_code']]);
|
|
|
|
$description = implode('<br><br>', $description);
|
|
|
|
/*echo view('emails.offerMail', compact('mailParams', 'description'));
|
|
die();*/
|
|
|
|
return $this->from($mailSenderAddress, 'Extranetwork - ' . $mailParams['property_name'])
|
|
->view('emails.offerMail', compact('mailParams', 'description'))
|
|
->to($mailParams['to'])
|
|
->bcc($mailParams['bcc'])
|
|
->subject(__('api-mailing-offer_mail-title', ['propertyName' => $offerDetail['property']['name'], 'code' => $offerDetail['ticket_code']]))
|
|
->with(['message' => $this]);
|
|
|
|
|
|
} catch (Exception $e) {
|
|
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
|
Log::error($message);
|
|
return output(['status' => -1, 'message' => $e->getMessage()]);
|
|
}
|
|
}
|
|
|
|
}
|