Deploy Ladill Events / deploy (push) Successful in 1m39s
Upload logo in account settings and prefer it over Ladill product marks in event notification headers. Co-authored-by: Cursor <cursoragent@cursor.com>
151 lines
4.2 KiB
PHP
151 lines
4.2 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Events;
|
|
|
|
use App\Support\AccountBranding;
|
|
use Illuminate\Support\Facades\View;
|
|
|
|
class EventEmailService
|
|
{
|
|
public function __construct(private readonly EventMailer $mailer) {}
|
|
|
|
public function lastError(): ?string
|
|
{
|
|
return $this->mailer->lastError();
|
|
}
|
|
|
|
public function sendProgrammeShare(
|
|
string $ownerPublicId,
|
|
string $to,
|
|
string $eventName,
|
|
string $programmeUrl,
|
|
?string $attendeeName = null,
|
|
?string $organizerEmail = null,
|
|
?string $organizerName = null,
|
|
): bool {
|
|
return $this->send(
|
|
$ownerPublicId,
|
|
$to,
|
|
'Programme for '.$eventName,
|
|
'mail.notifications.event-programme',
|
|
compact('eventName', 'programmeUrl', 'attendeeName'),
|
|
$organizerEmail,
|
|
$organizerName,
|
|
);
|
|
}
|
|
|
|
public function sendJoinLink(
|
|
string $ownerPublicId,
|
|
string $to,
|
|
string $eventName,
|
|
string $joinUrl,
|
|
?string $attendeeName = null,
|
|
?string $organizerEmail = null,
|
|
?string $organizerName = null,
|
|
): bool {
|
|
return $this->send(
|
|
$ownerPublicId,
|
|
$to,
|
|
'Join '.$eventName,
|
|
'mail.notifications.event-join',
|
|
compact('eventName', 'joinUrl', 'attendeeName'),
|
|
$organizerEmail,
|
|
$organizerName,
|
|
);
|
|
}
|
|
|
|
public function sendJoinAndProgramme(
|
|
string $ownerPublicId,
|
|
string $to,
|
|
string $eventName,
|
|
string $joinUrl,
|
|
string $programmeUrl,
|
|
?string $attendeeName = null,
|
|
?string $organizerEmail = null,
|
|
?string $organizerName = null,
|
|
): bool {
|
|
return $this->send(
|
|
$ownerPublicId,
|
|
$to,
|
|
$eventName.' — programme & join link',
|
|
'mail.notifications.event-join-programme',
|
|
compact('eventName', 'joinUrl', 'programmeUrl', 'attendeeName'),
|
|
$organizerEmail,
|
|
$organizerName,
|
|
);
|
|
}
|
|
|
|
public function sendRegistrationConfirmation(
|
|
string $ownerPublicId,
|
|
string $to,
|
|
string $eventName,
|
|
string $badgeCode,
|
|
?string $joinUrl = null,
|
|
?string $attendeeName = null,
|
|
?string $organizerEmail = null,
|
|
?string $organizerName = null,
|
|
): bool {
|
|
return $this->send(
|
|
$ownerPublicId,
|
|
$to,
|
|
'Registration confirmed — '.$eventName,
|
|
'mail.notifications.event-registration-confirmed',
|
|
compact('eventName', 'badgeCode', 'joinUrl', 'attendeeName'),
|
|
$organizerEmail,
|
|
$organizerName,
|
|
);
|
|
}
|
|
|
|
public function sendSpeakerInvite(
|
|
string $ownerPublicId,
|
|
string $to,
|
|
string $eventName,
|
|
string $portalUrl,
|
|
?string $speakerName = null,
|
|
?string $organizerEmail = null,
|
|
?string $organizerName = null,
|
|
): bool {
|
|
return $this->send(
|
|
$ownerPublicId,
|
|
$to,
|
|
'Speaker invitation — '.$eventName,
|
|
'mail.notifications.event-speaker-invite',
|
|
[
|
|
'eventName' => $eventName,
|
|
'portalUrl' => $portalUrl,
|
|
'speakerName' => $speakerName,
|
|
],
|
|
$organizerEmail,
|
|
$organizerName,
|
|
);
|
|
}
|
|
|
|
/** @param array<string, mixed> $viewData */
|
|
private function send(
|
|
string $ownerPublicId,
|
|
string $to,
|
|
string $subject,
|
|
string $view,
|
|
array $viewData,
|
|
?string $replyToEmail = null,
|
|
?string $replyToName = null,
|
|
): bool {
|
|
$brandingSettings = AccountBranding::forOwnerRef($ownerPublicId);
|
|
$viewData['logoUrl'] = AccountBranding::emailLogoUrl($brandingSettings);
|
|
$viewData['companyName'] = AccountBranding::companyName($brandingSettings);
|
|
|
|
$html = View::make($view, $viewData)->render();
|
|
$text = strip_tags(str_replace(['<br>', '<br/>', '<br />'], "\n", $html));
|
|
|
|
return $this->mailer->send(
|
|
$ownerPublicId,
|
|
$to,
|
|
$subject,
|
|
$html,
|
|
$text,
|
|
$replyToEmail,
|
|
$replyToName,
|
|
);
|
|
}
|
|
}
|