app/Notifications/TwoFactorRecoveryNotification.php
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class TwoFactorRecoveryNotification extends Notification
{
use Queueable;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct(public $codes)
{
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
*/
public function via($notifiable): array
{
return [
'mail',
];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
*/
public function toMail($notifiable): MailMessage
{
$message = (new MailMessage())
->greeting('Hello '.$notifiable->name)
->line('Your two factor recovery codes are:');
foreach ($this->codes as $code) {
$message->line($code);
}
$message->line('Please keep these safe as they are your backup codes for logins.');
return $message;
}
}