$event->touch();
$this->data = $event;
+ /**
+ * @todo track unsubscribes
+ */
if($event->event === 'unsubscribed') {
- $event->user->unsubscribe();
+// $event->user->unsubscribe();
}
$recipientGroup = Arr::get($data, 'recipient_group');
$batch->subject = Arr::get($data, 'email.subject');
- $batch->content = ['body' => Arr::get($data, 'email.content')];
+ $batch->content = [
+ 'body' => Arr::get($data, 'email.content'),
+ 'link' => Arr::get($data, 'email.link')
+ ];
$batch->file_id = Arr::get($data, 'file.id');
$batch->sent_to = [];
$this->batch->content['body'],
$this->batch->subject,
$this->type,
- null,
+ $this->batch->content['link'] ?? null,
optional($this->batch->file)->coverUrl
))->render();
'subject' => $this->batch->subject,
'recipient-variables' => $variables,
'html' => $view,
- 'o:tag' => [$this->batch->getTag(), config('app.env').'_batch'],
+ 'o:tag' => [$this->batch->getTag(), config('app.env').'_batch_'.BatchMail::getView($this->type)],
'o:testmode' => config('mail.mailgun.test_mode', 'yes'),
];
public const MAIL_TYPE_NEWSLETTER = 2;
- protected array $viewMap = [
+ public const VIEW_MAP = [
self::MAIL_TYPE_PDF_FILE => 'batch-pdf',
self::MAIL_TYPE_NEWSLETTER => 'newsletter'
];
$this->image = $image;
- $this->emailView = Arr::get($this->viewMap, $type ?? 0);
+ $this->emailView = self::getView($type);
$this->content = $this->emailView === 'batch-pdf' ?
(Html2Markdown::convert($content)) :
}
}
+ /**
+ * @param $id
+ * @return string
+ */
+ public static function getView($id)
+ {
+ return Arr::get(self::VIEW_MAP, $id ?? 0);
+ }
+
/**
* Build the message.
*