otp = $otp; $this->prefer = $prefer; } /** * Get the notification's delivery channels. * * @param mixed $notifiable * @return array */ public function via($notifiable) { return $this->prefer == "wa" ? [WahitsChannel::class] : ["mail"]; } /** * Get the mail representation of the notification. * * @param mixed $notifiable * @return \Illuminate\Notifications\Messages\MailMessage */ public function toMail($notifiable) { return (new MailMessage) ->subject('Your One-Time Password (OTP)') ->greeting('Hi '.$notifiable->name) ->line('Your One-Time Password (OTP) is:') ->line("**{$this->otp}**") ->line('This code is valid for 10 minutes.') ->line('If you did not request this, please ignore this email.') ->salutation('Regards, Asia Golf'); } /** * Get the array representation of the notification. * * @param mixed $notifiable * @return array */ public function toWa($notifiable) { $otp = $this->otp; return [ "text" => "$otp ini adalah kode OTP untuk anda login. JANGAN berikan kode OTP ke siapapun!" ]; } }