Preview: PresentationSubmittedMailToPresenters.php
Size: 5.12 KB
/var/www/multi-event-cfp.bitkit.dk/httpdocs/app/Mail/PresentationSubmittedMailToPresenters.php
<?php
namespace App\Mail;
use App\Models\Presentation;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use App\Lib\EmailSetupHelper;
class PresentationSubmittedMailToPresenters extends Mailable
{
use Queueable, SerializesModels;
protected $presentation;
protected $submitter;
protected $userType;
protected $presenters;
protected $password;
protected $emailSetup;
const KEY_TO_NEW_USER = "presentation_create_submitted_new_presenters";
const KEY_TO_EXISTING_USER = "presentation_create_submitted_existing_presenters";
/**
* Create a new message instance.
*
* @return void
*/
public function __construct(Presentation $presentation, $submitter, $userType, $presenters, $password = null)
{
$this->presentation = $presentation;
$this->submitter = $submitter;
$this->userType = $userType;
$this->presenters = $presenters;
$this->password = $password;
$this->emailSetup = new EmailSetupHelper();
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
$emailContents = $this->emailSetup->getEmailData($this->presentation->event->id,$this->userType == 'existing' ? self::KEY_TO_EXISTING_USER : self::KEY_TO_NEW_USER);
$logo = config('app.url') . '/' . $this->presentation->event->theme['logo']['value'];
$eventHeader = $this->presentation->event->event_name;
$presentationTitle = $this->presentation->data[0]['value'];
$eventUrl = $this->presentation->event->eventUrl('submitter');
$presentationUrl = $eventUrl . "presentation/{$this->presentation->id}";
Log::info($eventUrl);
Log::info($presentationUrl);
$presentationViewLink = $this->emailSetup->formatLinks($emailContents->body,'presentation_view_link_title',$presentationUrl);
$eventViewLink = $this->emailSetup->formatLinks($emailContents->body,'event_view_link_title',$eventUrl);
$variables=[
'presenter_name' => $this->presenters->name,
'presentation_title' => $presentationTitle,
'submitter_name' => $this->submitter->name,
'event_name' => $this->presentation->event->event_name,
'presentation_view_link' => $presentationViewLink,
'event_view_link' => $eventViewLink,
'username' => $this->presenters->email,
'password' => $this->userType != 'existing' ? $this->password : '',
'abstract_id' => $this->presentation->abstract_id ? $this->presentation->abstract_id : ''
];
$subject = $this->emailSetup->formatEmailBody($emailContents->subject,$variables);
$body = $this->emailSetup->formatEmailBody($emailContents->body,$variables);
$body = $this->emailSetup->removeLinkTitleFromBody($body,'presentation_view_link_title');
$body = html_entity_decode($this->emailSetup->removeLinkTitleFromBody($body,'event_view_link_title'));
// if ($this->userType == 'existing') {
// $body = "
// <p>
// Hi {$this->presenters->name},<br/><br>
// You have been added as a presenter
// to a new presentation
// <b> {$presentationTitle} </b>
// by {$this->submitter->name}.
// <br><br>
// To view the presentation, please click <a href={$presentationUrl}>{$presentationUrl}</a><br><br>
// You can login to the {$this->presentation->event->event_name}
// using the below details to amend your
// profile.<br><br>
// Link : <a href={$eventUrl}>{$eventUrl}</a><br>
// Username : {$this->presenters->email} <br>
// <br>
// Thank you,<br>
// {$this->presentation->event->event_name} Team<br>
// </p>
// ";
// } else {
// $body = "
// <p>
// Hi {$this->presenters->name},<br/><br>
// You have been added as a presenter
// to a new presentation
// <b> {$presentationTitle} </b>
// by {$this->submitter->name}.
// <br><br>
// To view the presentation, please click <a href={$presentationUrl}>{$presentationUrl}</a><br><br>
// You can login to the {$this->presentation->event->event_name}
// using the below details to amend your
// profile.<br><br>
// Link : <a href={$eventUrl}>{$eventUrl}</a><br>
// Username : {$this->presenters->email}<br>
// password : {$this->password}<br>
// <br>
// Thank you<br>
// {$this->presentation->event->event_name} Team<br>
// </p>
// ";
// }
return $this->from(config('app.admin_mail', 'Presenters'), $this->presentation->event->event_name)
->subject($subject)
->view('emails.presentation.presentation_submitted')
->with([
"body" => $body,
"eventHeader" => $eventHeader,
"logo" => $logo
]);
}
}
Directory Contents
Dirs: 0 × Files: 34