NodeOffline.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace App\Notifications;
  3. use Illuminate\Bus\Queueable;
  4. use Illuminate\Contracts\Queue\ShouldQueue;
  5. use Illuminate\Notifications\Messages\MailMessage;
  6. use Illuminate\Notifications\Notification;
  7. class NodeOffline extends Notification implements ShouldQueue
  8. {
  9. use Queueable;
  10. private $content;
  11. public function __construct($nodes)
  12. {
  13. $content = '### '.trans('notification.node_offline_content')."\r\n";
  14. foreach ($nodes as $node) {
  15. $content .= "- {$node['name']} [{$node['ip']}]\r\n";
  16. }
  17. $this->content = $content;
  18. }
  19. public function via($notifiable)
  20. {
  21. return sysConfig('node_offline_notification');
  22. }
  23. public function toMail($notifiable)
  24. {
  25. return (new MailMessage)
  26. ->subject(trans('notification.node_offline'))
  27. ->markdown('mail.node.offline', ['content' => $this->content]);
  28. }
  29. public function toCustom($notifiable)
  30. {
  31. return [
  32. 'title' => trans('notification.node_offline'),
  33. 'content' => $this->content,
  34. ];
  35. }
  36. }