Spaces:
Running
Running
File size: 1,545 Bytes
907b200 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | <?php
namespace App\Notifications;
// use Illuminate\Bus\Queueable;
// use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class SendOtpNotification extends Notification // implements ShouldQueue
{
// use Queueable;
protected $otp;
protected $type;
public function __construct(int $otp, string $type)
{
$this->otp = $otp;
$this->type = $type;
}
public function via(object $notifiable): array
{
return ['mail'];
}
public function toMail(object $notifiable): MailMessage
{
$subject = match ($this->type) {
'password_reset' => 'Reset Your Password - OTP Code',
'email_verification' => 'Verify Your Email - OTP Code',
default => 'Your OTP Code'
};
$message = match ($this->type) {
'password_reset' => 'Use this code to reset your password.',
'email_verification' => 'Use this code to verify your email address.',
default => 'Your verification code is:'
};
return (new MailMessage)
->subject($subject . ' - ' . config('app.name'))
->greeting('Hello ' . $notifiable->name . '!')
->line($message)
->line('**' . $this->otp . '**')
->line('This code expires in 5 minutes.')
->line('If you did not request this, please ignore this email.')
->salutation('Regards, ' . config('app.name'));
}
}
|