Preview: AbstractSelected.php
Size: 4.57 KB
/var/www/multi-event-cfp.bitkit.dk/httpdocs/app/Mail/AbstractSelected.php
<?php
namespace App\Mail;
use App\Models\Abstracts;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use App\Lib\EmailSetupHelper;
class AbstractSelected extends Mailable
{
use Queueable, SerializesModels;
protected $abstract;
protected $emailSetup;
const KEY_TO_SUBMITTER_ABS_ACCEPT = "abstract_selected_accept";
const KEY_TO_SUBMITTER_ABS_ACCEPT_RESERVE = "abstract_selected_accept_reserve";
const KEY_TO_SUBMITTER_ABS_REJECT = "abstract_selected_reject";
const KEY_TO_SUBMITTER_ABS_ACCEPT_PROVI = "abstract_selected_provisionally_accept";
const KEY_TO_SUBMITTER_ABS_ACCEPT_PROVI_RESERVE = "abstract_selected_provisionally_accept_reserve";
/**
* Create a new message instance.
*
* @return void
*/
public function __construct(Abstracts $abstract)
{
$this->abstract = $abstract;
$this->emailSetup = new EmailSetupHelper();
$this->formSettings = $this->abstract->event->form_settings;
$this->abstractData = $this->abstract->data;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
$key = '';
if ($this->abstract->selection_status == "Accepted") {
$key = self::KEY_TO_SUBMITTER_ABS_ACCEPT;
} elseif ($this->abstract->selection_status == "Rejected") {
$key = self::KEY_TO_SUBMITTER_ABS_REJECT;
} elseif ($this->abstract->selection_status == "Accepted Reserve") {
$key = self::KEY_TO_SUBMITTER_ABS_ACCEPT_RESERVE;
} elseif ($this->abstract->selection_status == "Provisionally Accepted") {
$key = self::KEY_TO_SUBMITTER_ABS_ACCEPT_PROVI;
} elseif ($this->abstract->selection_status == "Provisionally Accepted Reserved") {
$key = self::KEY_TO_SUBMITTER_ABS_ACCEPT_PROVI_RESERVE;
}
$emailContents = $this->emailSetup->getEmailData($this->abstract->event->id, $key);
$logo = config('app.url') . '/' . $this->abstract->event->theme['logo']['value'];
$eventHeader = $this->abstract->event->event_name;
$eventUrl = $this->abstract->event->eventUrl('submitter');
$presentationUrl = $eventUrl . "presentations";
$abstractSubmitter = $this->abstract->users('abstract_submitter')->first();
$abstractSubmitterUserName = $abstractSubmitter->name;
$presentationViewLink = $this->emailSetup->formatLinks($emailContents->body, 'presentation_view_link_title', $presentationUrl);
// $reservePaperContent = $this->abstract->selection_status == "Accepted" ? '.<br>' : ' as a reserve paper.';
$titleLabel = getField($this->formSettings, 'title')[0]['label'] ? getField($this->formSettings, 'title')[0]['label'] : '';
$titleField = getField($this->abstractData, 'title');
if (!empty($titleField)) {
$titleValue = isset($titleField[0]['value']) ? $titleField[0]['value'] : '';
} else {
$titleValue = '';
}
$variables = [
'event_name' => $this->abstract->event->event_name,
'submitter_name' => $abstractSubmitterUserName,
'presentation_view_link' => $presentationViewLink,
'abstract_id' => $this->abstract->id,
"abstract_title_label" => $titleLabel,
"abstract_title_value" => $titleValue,
];
$subject = $this->emailSetup->formatEmailBody($emailContents->subject, $variables);
$body = $this->emailSetup->formatEmailBody($emailContents->body, $variables);
$body = html_entity_decode($this->emailSetup->removeLinkTitleFromBody($body, 'presentation_view_link_title'));
// $body = "
// <p>
// Hi $abstractSubmitterUserName,<br/><br>
// The abstract you submitted in the {$this->abstract->event->event_name} has been accepted
// by the selection committee$reservePaperContent
// Login to accept your invitation and complete outstanding requirements.<br/><br/>
// Link : <a href={$presentationUrl}>$presentationUrl</a><br>
// <br>
// Thank you,<br>
// {$this->abstract->event->event_name} Team<br>
// </p>
// ";
return $this->from(config('app.admin_mail', 'Admin'), $this->abstract->event->event_name)
->subject($subject)
->view('emails.submitter.abstract_selected')
->with([
"body" => $body,
"eventHeader" => $eventHeader,
"logo" => $logo
]);
}
}
Directory Contents
Dirs: 0 × Files: 34