Ten*_*ake 3 email passwords routing reset laravel
我试图覆盖放置在电子邮件中的actionUrl以重置用户帐户。但是无论我做什么,它都保持不变。我尝试在Route文件中覆盖。有谁能够帮助我 ?
这是我的路线文件中的路线:
Route::get('cms/password/reset/{token}', 'Auth\ResetPasswordController@showResetForm');
Run Code Online (Sandbox Code Playgroud)
这是我的电子邮件模板:
<p style="{{ $style['paragraph-sub'] }}">
<a style="{{ $style['anchor'] }}" href="{{ $actionUrl }}" target="_blank">
{{ $actionUrl }}
</a>
</p>`
Run Code Online (Sandbox Code Playgroud)
我知道actionUrl是在SimpleMessage.php中定义的,但我不知道它的设置位置。
链接设置为Illuminate\Auth\Notifications\ResetPassword。这是关于密码重置请求的通知。
此通知被初始化,Illuminate\Auth\Passwords\CanResetPassword其中的特质是App\User模型以外的任何地方。
因此,您要做的就是创建自己的重置通知并覆盖模型sendPasswordResetNotification上的方法User,如下所示:
php artisan make:notification MyResetPasswordNotification
编辑 app/Notifications/MyResetPasswordNotification.php
<?php
namespace App\Notifications;
use Illuminate\Notifications\Messages\MailMessage;
class MyResetPasswordNotification extends \Illuminate\Auth\Notifications\ResetPassword
{
/**
* Build the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->line('You are receiving this email because we received a password reset request for your account.')
->action('Reset Password', url('YOUR URL', $this->token))
->line('If you did not request a password reset, no further action is required.');
}
}
Run Code Online (Sandbox Code Playgroud)
然后添加到 app/User.php
/**
* Send the password reset notification.
*
* @param string $token
* @return void
*/
public function sendPasswordResetNotification($token)
{
$this->notify(new \App\Notifications\MyResetPasswordNotification($token));
}
Run Code Online (Sandbox Code Playgroud)
当然,您需要像在问题中所写的那样创建自己的路线,并且还必须更改刀片视图。
| 归档时间: |
|
| 查看次数: |
1396 次 |
| 最近记录: |