Changeset View
Changeset View
Standalone View
Standalone View
src/app/Mail/SuspendedDebtor.php
Show All 34 Lines | class SuspendedDebtor extends Mailable | ||||
* @return $this | * @return $this | ||||
*/ | */ | ||||
public function build() | public function build() | ||||
{ | { | ||||
$user = $this->account; | $user = $this->account; | ||||
$subject = \trans('mail.suspendeddebtor-subject', ['site' => \config('app.name')]); | $subject = \trans('mail.suspendeddebtor-subject', ['site' => \config('app.name')]); | ||||
$moreInfo = null; | $moreInfoHtml = null; | ||||
$moreInfoText = null; | |||||
if ($moreInfoUrl = \config('app.kb.account_suspended')) { | if ($moreInfoUrl = \config('app.kb.account_suspended')) { | ||||
$moreInfo = \trans('mail.more-info-html', ['href' => $moreInfoUrl]); | $moreInfoHtml = \trans('mail.more-info-html', ['href' => $moreInfoUrl]); | ||||
$moreInfoText = \trans('mail.more-info-text', ['href' => $moreInfoUrl]); | |||||
} | } | ||||
$this->view('emails.suspended_debtor') | $this->view('emails.html.suspended_debtor') | ||||
->text('emails.plain.suspended_debtor') | |||||
->subject($subject) | ->subject($subject) | ||||
->with([ | ->with([ | ||||
'site' => \config('app.name'), | 'site' => \config('app.name'), | ||||
'subject' => $subject, | 'subject' => $subject, | ||||
'username' => $user->name(true), | 'username' => $user->name(true), | ||||
'cancelUrl' => \config('app.kb.account_delete'), | 'cancelUrl' => \config('app.kb.account_delete'), | ||||
'supportUrl' => \config('app.support_url'), | 'supportUrl' => \config('app.support_url'), | ||||
'walletUrl' => Utils::serviceUrl('/wallet'), | 'walletUrl' => Utils::serviceUrl('/wallet'), | ||||
'moreInfo' => $moreInfo, | 'moreInfoHtml' => $moreInfoHtml, | ||||
'moreInfoText' => $moreInfoText, | |||||
'days' => 14 // TODO: Configurable | 'days' => 14 // TODO: Configurable | ||||
]); | ]); | ||||
return $this; | return $this; | ||||
} | } | ||||
/** | /** | ||||
* Render the mail template with fake data | * Render the mail template with fake data | ||||
* | * | ||||
* @return string HTML output | * @param string $type Output format ('html' or 'text') | ||||
* | |||||
* @return string HTML or Plain Text output | |||||
*/ | */ | ||||
public static function fakeRender(): string | public static function fakeRender(string $type = 'html'): string | ||||
{ | { | ||||
$user = new User(); | $user = new User(); | ||||
if (!\config('app.support_url')) { | |||||
\config(['app.support_url' => 'https://not-configured-support.url']); | |||||
} | |||||
if (!\config('app.kb.account_delete')) { | |||||
\config(['app.kb.account_delete' => 'https://not-configured-kb.url']); | |||||
} | |||||
if (!\config('app.kb.account_suspended')) { | |||||
\config(['app.kb.account_suspended' => 'https://not-configured-kb.url']); | |||||
} | |||||
$mail = new self($user); | $mail = new self($user); | ||||
return $mail->build()->render(); | return Helper::render($mail, $type); | ||||
} | } | ||||
} | } |