NodeDailyReport.php 1.3 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 NodeDailyReport extends Notification implements ShouldQueue
  8. {
  9. use Queueable;
  10. private $content;
  11. public function __construct($nodes)
  12. {
  13. $content = '| '.trans('user.attribute.node').' | '.trans('notification.node.upload').' | '.trans('notification.node.download').' | '.trans('notification.node.total')." |\r\n| ------ | :------: | :------: | ------: |\r\n";
  14. foreach ($nodes as $node) {
  15. $content .= "| {$node['name']} | {$node['upload']} | {$node['download']} | {$node['total']} |\r\n";
  16. }
  17. $this->content = $content;
  18. }
  19. public function via($notifiable)
  20. {
  21. return sysConfig('node_daily_notification');
  22. }
  23. public function toMail($notifiable)
  24. {
  25. return (new MailMessage)
  26. ->subject(__('Nodes Daily Report'))
  27. ->markdown('mail.node.dailyReport', ['content' => $this->content]);
  28. }
  29. public function toCustom($notifiable)
  30. {
  31. return [
  32. 'title' => __('Nodes Daily Report'),
  33. 'content' => $this->content,
  34. ];
  35. }
  36. }