通知メールにユーザーの名前を追加しようとしています。私はセットアップこの等を有していて、今Laravel 5.3通知でユーザー名を表示する方法
Hello Donald,
:現時点では、Laravelの通知メールは次のように起動します:
Hello,
そして、私はそれを変更したいです。
ユーザーモデル::
public function sendPasswordResetNotification($token)
{
$this->notify(new PasswordReset($token));
}
のApp \通知\ PasswordReset:
class PasswordReset extends Notification
{
use Queueable;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* 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)
->line('The introduction to the notification.')
->action('Notification Action', 'https://laravel.com')
->line('Thank you for using our application!');
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}
が自動的に通知してバインドさユーザモデルであり、この例では、パスワードリセット通知メールのためでありますクラス?ビューにユーザー名を追加するにはどうすればいいですか?
今、あなたの電子メールは、ユーザ名を指定せずに送信しますか? –
はい。これはデフォルトである通知メールで 'Hello!'で始まります。 '$ user-> first_name'または' $ first_name'をブレードに追加すると、未定義の変数エラーがスローされます。だから私は、ユーザーオブジェクトは、通知クラスから送信する必要があると思いますか? – Neel
これとビューのメールクラスを作成しましたか? –