Preview: PresentationStatusChangeMail.php
Size: 4.22 KB
/var/www/multi-event-cfp.bitkit.dk/httpdocs/app/Mail/PresentationStatusChangeMail.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 PresentationStatusChangeMail extends Mailable
{
use Queueable, SerializesModels;
protected $presentation;
protected $emailSetup;
const KEY_TO_SUBMITTER_DRAFT = 'presentation_status_change_to_draft_submitter';
const KEY_TO_SUBMITTER_SUBMITTED = 'presentation_status_change_to_submitted_submitter';
/**
* Create a new message instance.
*
* @return void
*/
public function __construct(Presentation $presentation)
{
$this->presentation = $presentation;
$this->emailSetup = new EmailSetupHelper();
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
$emailContents = $this->emailSetup->getEmailData($this->presentation->event->id,$this->presentation->submission_status == 'Draft' ? self::KEY_TO_SUBMITTER_DRAFT : self::KEY_TO_SUBMITTER_SUBMITTED);
$logo = config('app.url') . '/' . $this->presentation->event->theme['logo']['value'];
$eventHeader = $this->presentation->event->event_name;
$eventUrl = $this->presentation->event->eventUrl('submitter');
$presentationUrl = $eventUrl . "presentation/{$this->presentation->id}";
Log::info($eventUrl);
Log::info($presentationUrl);
$presentationEditLink = $this->emailSetup->formatLinks($emailContents->body,'presentation_edit_link_title',$presentationUrl);
$presentationViewLink = $this->emailSetup->formatLinks($emailContents->body,'presentation_view_link_title',$presentationUrl);
$variables=[
'presentation_id' => $this->presentation->id,
'event_name' => $this->presentation->event->event_name,
'presentation_submission_status' => $this->presentation->submission_status,
'presentation_edit_link' => $presentationEditLink,
'presentation_view_link' => $presentationViewLink,
'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_edit_link_title');
$body = html_entity_decode($this->emailSetup->removeLinkTitleFromBody($body,'presentation_view_link_title'));
// if ($this->presentation->submission_status == "Draft") {
// $body = "
// <p>
// Hi,<br/><br>
// {$this->presentation->event->event_name} admin has changed the status of presentation #{$this->presentation->id} to
// {$this->presentation->submission_status}<br><br>
// Please click the link below to edit your presentation.<br>
// Link : <a href={$presentationUrl}>Edit Presentation</a><br>
// <br>
// Thank you,<br>
// {$this->presentation->event->event_name} Team<br>
// </p>
// ";
// } else {
// $body = "
// <p>
// Hi,<br/><br>
// {$this->presentation->event->event_name} admin has changed the status of presentation #{$this->presentation->id} to
// {$this->presentation->submission_status}<br><br>
// Please click the link below to view your presentation.<br>
// Link : <a href={$presentationUrl}>View Presentation</a><br>
// <br>
// Thank you<br>
// {$this->presentation->event->event_name} Team<br>
// </p>
// ";
// }
return $this->from(config('app.admin_mail', 'Submitter'), $this->presentation->event->event_name)
->subject($subject)
->view('emails.presentation.presentation_status_change')
->with([
"body" => $body,
"eventHeader" => $eventHeader,
"logo" => $logo
]);
}
}
Directory Contents
Dirs: 0 × Files: 34