您可以更改您的密码重置电子邮件主题,但它需要一些额外的工作。首先,您需要创建自己的ResetPassword
通知的实现。
内app\Notifications
目录下创建一个新的通知类,让我们ResetPassword.php
将其命名为:
<?php
namespace App\Notifications;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\MailMessage;
class ResetPassword extends Notification
{
public $token;
public function __construct($token)
{
$this->token = $token;
}
public function via($notifiable)
{
return ['mail'];
}
public function toMail($notifiable)
{
return (new MailMessage)
->subject('Your Reset Password Subject Here')
->line('You are receiving this email because we received a password reset request for your account.')
->action('Reset Password', url('password/reset', $this->token))
->line('If you did not request a password reset, no further action is required.');
}
}
您也可以使用Artisan命令生成的通知模板:
php artisan make:notification ResetPassword
或者你可以简单地复制粘贴上面的代码。您可能会注意到,此通知类与默认的Illuminate\Auth\Notifications\ResetPassword
非常相似。实际上,您可以从默认的ResetPassword
类中扩展它。
唯一的区别就在这里,你添加一个新的方法调用来定义邮件的主题:
return (new MailMessage)
->subject('Your Reset Password Subject Here')
你可以阅读更多关于Mail Notifications here。其次,在您的app\User.php
文件中,您需要覆盖Illuminate\Auth\Passwords\CanResetPassword
特征定义的默认sendPasswordResetNotification()
方法。现在,你应该用你自己的ResetPassword
实现:
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use App\Notifications\ResetPassword as ResetPasswordNotification;
class User extends Authenticatable
{
use Notifiable;
...
public function sendPasswordResetNotification($token)
{
// Your your own implementation.
$this->notify(new ResetPasswordNotification($token));
}
}
现在你重设密码电子邮件主题应该更新!
希望这有助于!
,我们如何才能改变Laravel和Laravel的问题。 – Steve
@Steve转到config/app.php并更改应用程序名称 – kniteli