gpt4 book ai didi

Laravel 电子邮件验证模板位置

转载 作者:行者123 更新时间:2023-12-03 14:30:46 26 4
gpt4 key购买 nike

我一直在阅读有关 laravel 电子邮件验证新功能的文档。在哪里可以找到发送给用户的电子邮件模板?此处不显示:https://laravel.com/docs/5.7/verification#after-verifying-emails

最佳答案

Laravel 使用了 VerifyEmail 的这种方法发送电子邮件的通知类:

public function toMail($notifiable)
{
if (static::$toMailCallback) {
return call_user_func(static::$toMailCallback, $notifiable);
}
return (new MailMessage)
->subject(Lang::getFromJson('Verify Email Address'))
->line(Lang::getFromJson('Please click the button below to verify your email address.'))
->action(
Lang::getFromJson('Verify Email Address'),
$this->verificationUrl($notifiable)
)
->line(Lang::getFromJson('If you did not create an account, no further action is required.'));
}

Method in source code .

如果您想使用自己的电子邮件模板,您可以扩展基本通知类。

1) 创建于 app/Notifications/文件 VerifyEmail.php
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Facades\Lang;
use Illuminate\Auth\Notifications\VerifyEmail as VerifyEmailBase;

class VerifyEmail extends VerifyEmailBase
{
// use Queueable;

// change as you want
public function toMail($notifiable)
{
if (static::$toMailCallback) {
return call_user_func(static::$toMailCallback, $notifiable);
}
return (new MailMessage)
->subject(Lang::getFromJson('Verify Email Address'))
->line(Lang::getFromJson('Please click the button below to verify your email address.'))
->action(
Lang::getFromJson('Verify Email Address'),
$this->verificationUrl($notifiable)
)
->line(Lang::getFromJson('If you did not create an account, no further action is required.'));
}
}

2)添加到用户模型:
use App\Notifications\VerifyEmail;


/**
* Send the email verification notification.
*
* @return void
*/
public function sendEmailVerificationNotification()
{
$this->notify(new VerifyEmail); // my notification
}

另外,如果您需要 Blade 模板:

laravel will generate all of the necessary email verification views when the make:auth command is executed. This view is placed in resources/views/auth/verify.blade.php. You are free to customize this view as needed for your application.



Source .

关于Laravel 电子邮件验证模板位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52231870/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com