- Password generation controller
- Add Route
- Send e-mail page
- Notify Send e-mail use
Generating notify file
artisan make:notification findEmailNotify
Edit the message content in a file
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class findEmailNotify extends Notification
{
use Queueable;
protected $token;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($token)
{
$this->token = $token;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->subject('找回密码') // 标题
->line('点击链接找回密码')
->action('重置密码', url(route('passwordEmailEdit', [$this->token])))
->line('感谢您的使用');
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}
The controller sends a message
\Notification::send($user, new findEmailNotify($user->email_token));
You can modify the template HTML and Plain Text Templates notice issued by resource package. After running this command, the mail notification template was placed on the resources / views / vendor / notifications folder:
php artisan vendor:publish --tag=laravel-notifications
- Password change page
- Password Update