<?php
namespace App\Notifications;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\MailMessage;
class ResetPasswordNotification 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('パスワードの再発行')
->line("パスワード再発行のリクエストを受け付けました。こちらのボタンを押してパスワードを再設定してください。")
->action('パスワードを再発行する', route('password.reset', $this->token))
->line('もしこのメールに心当たりがない場合はこのメールを破棄してください。');
}
}
/app/User.php
/**
* オリジナルのパスワード再発行メールを送信する
*
* @param string $token
* @return void
*/
public function sendPasswordResetNotification($token)
{
$this->notify(new \App\Notifications\ResetPasswordNotification($token));
}
以上です。簡単ですね。