Browse Source

Fix 部分通知未正确使用内容

兔姬桑 4 years ago
parent
commit
48978dd506
2 changed files with 8 additions and 6 deletions
  1. 4 3
      app/Notifications/DataAnomaly.php
  2. 4 3
      app/Notifications/TicketClosed.php

+ 4 - 3
app/Notifications/DataAnomaly.php

@@ -11,13 +11,14 @@ class DataAnomaly extends Notification implements ShouldQueue
 {
     use Queueable;
 
+    private $userId;
     private $upload;
     private $download;
     private $total;
 
     public function __construct($id, $upload, $download, $total)
     {
-        $this->id = $id;
+        $this->userId = $id;
         $this->upload = $upload;
         $this->download = $download;
         $this->total = $total;
@@ -32,14 +33,14 @@ class DataAnomaly extends Notification implements ShouldQueue
     {
         return (new MailMessage)
             ->subject(trans('notification.data_anomaly'))
-            ->line(trans('notification.data_anomaly_content', ['id' => $this->id, 'upload' => $this->upload, 'download' => $this->download, 'total' => $this->total]));
+            ->line(trans('notification.data_anomaly_content', ['id' => $this->userId, 'upload' => $this->upload, 'download' => $this->download, 'total' => $this->total]));
     }
 
     public function toCustom($notifiable)
     {
         return [
             'title'   => trans('notification.data_anomaly'),
-            'content' => trans('notification.data_anomaly_content', ['id' => $this->id, 'upload' => $this->upload, 'download' => $this->download, 'total' => $this->total]),
+            'content' => trans('notification.data_anomaly_content', ['id' => $this->userId, 'upload' => $this->upload, 'download' => $this->download, 'total' => $this->total]),
         ];
     }
 }

+ 4 - 3
app/Notifications/TicketClosed.php

@@ -11,6 +11,7 @@ class TicketClosed extends Notification implements ShouldQueue
 {
     use Queueable;
 
+    private $ticketId;
     private $title;
     private $url;
     private $reason;
@@ -18,7 +19,7 @@ class TicketClosed extends Notification implements ShouldQueue
 
     public function __construct($id, $title, $url, $reason, $is_user = null)
     {
-        $this->id = $id;
+        $this->ticketId = $id;
         $this->title = $title;
         $this->url = $url;
         $this->reason = $reason;
@@ -33,7 +34,7 @@ class TicketClosed extends Notification implements ShouldQueue
     public function toMail($notifiable)
     {
         return (new MailMessage)
-            ->subject(trans('notification.close_ticket', ['id' => $this->id, 'title' => $this->title]))
+            ->subject(trans('notification.close_ticket', ['id' => $this->ticketId, 'title' => $this->title]))
             ->line($this->reason)
             ->action(trans('notification.view_ticket'), $this->url)
             ->line(__('If your problem has not been solved, Feel free to open other one.'));
@@ -42,7 +43,7 @@ class TicketClosed extends Notification implements ShouldQueue
     public function toCustom($notifiable)
     {
         return [
-            'title'   => trans('notification.close_ticket', ['id' => $this->id, 'title' => $this->title]),
+            'title'   => trans('notification.close_ticket', ['id' => $this->ticketId, 'title' => $this->title]),
             'content' => $this->reason,
         ];
     }