newUser = $newUser; } /** * Get the notification's delivery channels. * * @return array */ public function via(object $notifiable): array { $channels = []; $prefs = $notifiable->preferences ?? []; // Se o admin quiser receber notificações de novos usuários if ($prefs['notifications_new_users'] ?? true) { if ($prefs['notifications_email'] ?? true) { $channels[] = 'mail'; } if ($prefs['notifications_system'] ?? true) { $channels[] = 'database'; } } return $channels; } /** * Get the mail representation of the notification. */ public function toMail(object $notifiable): MailMessage { return (new MailMessage) ->subject('Novo Usuário Cadastrado - ' . config('app.name')) ->greeting('Olá, ' . $notifiable->name) ->line('Um novo usuário acaba de se cadastrar no site.') ->line('**Nome:** ' . $this->newUser->name) ->line('**E-mail:** ' . $this->newUser->email) ->line('**Empresa:** ' . ($this->newUser->company ?? 'Não informado')) ->action('Gerenciar Usuários', route('admin.users.index')) ->line('Obrigado por usar nosso sistema!'); } /** * Get the array representation of the notification. * * @return array */ public function toArray(object $notifiable): array { return [ 'user_id' => $this->newUser->id, 'name' => $this->newUser->name, 'email' => $this->newUser->email, 'message' => 'Novo usuário cadastrado: ' . $this->newUser->name, 'link' => route('admin.users.edit', $this->newUser->id) ]; } }