server = $event->subuser->server; $this->user = $event->subuser->user; // Since we are calling this notification directly from an event listener we need to fire off the dispatcher // to send the email now. Don't use send() or you'll end up firing off two different events. Container::getInstance()->make(Dispatcher::class)->sendNow($this->user, $this); } /** * Get the notification's delivery channels. */ public function via(): array { return ['mail']; } /** * Get the mail representation of the notification. */ public function toMail(): MailMessage { return (new MailMessage()) ->greeting('Hello ' . $this->user->username . '!') ->line('You have been added as a subuser for the following server, allowing you certain control over the server.') ->line('Server Name: ' . $this->server->name) ->action('Visit Server', url('/server/' . $this->server->uuid_short)); } }