Changeset View
Changeset View
Standalone View
Standalone View
src/app/Mail/PasswordReset.php
Show All 36 Lines | class PasswordReset extends Mailable | ||||
* @return $this | * @return $this | ||||
*/ | */ | ||||
public function build() | public function build() | ||||
{ | { | ||||
$href = Utils::serviceUrl( | $href = Utils::serviceUrl( | ||||
sprintf('/login/reset/%s-%s', $this->code->short_code, $this->code->code) | sprintf('/login/reset/%s-%s', $this->code->short_code, $this->code->code) | ||||
); | ); | ||||
$this->view('emails.password_reset') | $this->view('emails.html.password_reset') | ||||
->text('emails.plain.password_reset') | |||||
->subject(__('mail.passwordreset-subject', ['site' => \config('app.name')])) | ->subject(__('mail.passwordreset-subject', ['site' => \config('app.name')])) | ||||
->with([ | ->with([ | ||||
'site' => \config('app.name'), | 'site' => \config('app.name'), | ||||
'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), | 'link' => sprintf('<a href="%s">%s</a>', $href, $href), | ||||
'username' => $this->code->user->name(true) | 'username' => $this->code->user->name(true) | ||||
]); | ]); | ||||
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 VerificationCode([ | $code = new VerificationCode([ | ||||
'code' => Str::random(VerificationCode::CODE_LENGTH), | 'code' => Str::random(VerificationCode::CODE_LENGTH), | ||||
'short_code' => VerificationCode::generateShortCode(), | 'short_code' => VerificationCode::generateShortCode(), | ||||
]); | ]); | ||||
$code->user = new User([ | $code->user = new User([ | ||||
'email' => 'test@' . \config('app.domain'), | 'email' => 'test@' . \config('app.domain'), | ||||
]); | ]); | ||||
$mail = new self($code); | $mail = new self($code); | ||||
return $mail->build()->render(); | return Helper::render($mail, $type); | ||||
} | } | ||||
} | } |