user.php
public function sendPasswordResetNotification($token)
{
$this->notify(new sendResetPassword($token));
}
My notification class
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
class sendResetPassword extends Notification
{
use Queueable;
public $token;
/**
* Create a new message 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)->markdown('emails.reset.send');
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}
In my notification class i get the token on function toMail. How can i pass it to markdown view? Always says undefined variable. O tried everything. This is probably something simple...
Solved.
public function toMail($notifiable)
{
$token = $this->token;
return (new MailMessage)->markdown('emails.reset.send', ['token' => $token]);
}
I knew it was something simple...
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community