user = $user; } /** * Get the array representation of the notification. * * @param mixed $notifiable * * @return array * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function toArray($notifiable) { return [ ]; } /** * Get the mail representation of the notification. * * @param mixed $notifiable * * @return MailMessage * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function toMail($notifiable) { $subject = (string)trans('email.new_backup_codes_subject'); return (new MailMessage())->markdown('emails.security.new-backup-codes', ['user' => $this->user])->subject($subject); } /** * Get the Slack representation of the notification. * * @param mixed $notifiable * * @return SlackMessage * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function toSlack($notifiable) { $message = (string)trans('email.new_backup_codes_slack', ['email' => $this->user->email]); return (new SlackMessage())->content($message); } /** * Get the notification's delivery channels. * * @param mixed $notifiable * * @return array * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function via($notifiable) { /** @var null|User $user */ $user = auth()->user(); $slackUrl = null === $user ? '' : app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data; if (is_array($slackUrl)) { $slackUrl = ''; } if (UrlValidator::isValidWebhookURL((string)$slackUrl)) { return ['mail', 'slack']; } return ['mail']; } }