Changeset View
Changeset View
Standalone View
Standalone View
src/app/Mail/SignupVerification.php
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | public function build() | ||||
); | ); | ||||
$username = $this->code->data['first_name'] ?? ''; | $username = $this->code->data['first_name'] ?? ''; | ||||
if (!empty($this->code->data['last_name'])) { | if (!empty($this->code->data['last_name'])) { | ||||
$username .= ' ' . $this->code->data['last_name']; | $username .= ' ' . $this->code->data['last_name']; | ||||
} | } | ||||
$username = trim($username); | $username = trim($username); | ||||
$this->view('emails.signup_code') | $this->view('emails.html.signup_code') | ||||
->text('emails.plain.signup_code') | |||||
->subject(__('mail.signupcode-subject', ['site' => \config('app.name')])) | ->subject(__('mail.signupcode-subject', ['site' => \config('app.name')])) | ||||
->with([ | ->with([ | ||||
'site' => \config('app.name'), | 'site' => \config('app.name'), | ||||
'username' => $username ?: 'User', | 'username' => $username ?: 'User', | ||||
'code' => $this->code->code, | 'code' => $this->code->code, | ||||
'short_code' => $this->code->short_code, | 'short_code' => $this->code->short_code, | ||||
'link' => sprintf('<a href="%s">%s</a>', $href, $href), | 'href' => $href, | ||||
]); | ]); | ||||
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 | ||||
{ | { | ||||
$code = new SignupCode([ | $code = new SignupCode([ | ||||
'code' => Str::random(SignupCode::CODE_LENGTH), | 'code' => Str::random(SignupCode::CODE_LENGTH), | ||||
'short_code' => SignupCode::generateShortCode(), | 'short_code' => SignupCode::generateShortCode(), | ||||
'data' => [ | 'data' => [ | ||||
'email' => 'test@' . \config('app.domain'), | 'email' => 'test@' . \config('app.domain'), | ||||
'first_name' => 'Firstname', | 'first_name' => 'Firstname', | ||||
'last_name' => 'Lastname', | 'last_name' => 'Lastname', | ||||
], | ], | ||||
]); | ]); | ||||
$mail = new self($code); | $mail = new self($code); | ||||
return $mail->build()->render(); | return Helper::render($mail, $type); | ||||
} | } | ||||
} | } |