gallery = $gallery; $this->user = $user; $this->action = $action; } /** * Get the notification's delivery channels. * * @return array */ public function via(object $notifiable): array { $channels = []; $prefs = $notifiable->preferences ?? []; if ($prefs['notifications_gallery_actions'] ?? 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 { $actionMap = [ 'created' => 'criada', 'updated' => 'atualizada', 'photo_added' => 'com nova foto adicionada', 'photo_deleted' => 'com foto removida', ]; $actionText = $actionMap[$this->action] ?? 'modificada'; return (new MailMessage) ->subject('Galeria ' . ucfirst($actionText) . ' - ' . config('app.name')) ->greeting('Olá, ' . $notifiable->name) ->line('Uma galeria de fotos foi ' . $actionText . ' por ' . $this->user->name . '.') ->line('**Título da Galeria:** ' . $this->gallery->title) ->action('Gerenciar Galerias', route('admin.galleries.index')) ->line('Obrigado por usar nosso sistema!'); } /** * Get the array representation of the notification. * * @return array */ public function toArray(object $notifiable): array { $actionMap = [ 'created' => 'criada', 'updated' => 'atualizada', 'photo_added' => 'foto adicionada', 'photo_deleted' => 'foto removida', ]; $actionText = $actionMap[$this->action] ?? 'modificada'; return [ 'gallery_id' => $this->gallery->id, 'name' => $this->user->name, 'email' => $this->user->email, 'action' => $this->action, 'message' => "Galeria '{$this->gallery->title}': {$actionText}.", 'link' => route('admin.galleries.edit', $this->gallery->id) ]; } }