DataAnomaly.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 DataAnomaly extends Notification implements ShouldQueue
  8. {
  9. use Queueable;
  10. private $userId;
  11. private $upload;
  12. private $download;
  13. private $total;
  14. public function __construct($userId, $upload, $download, $total)
  15. {
  16. $this->userId = $userId;
  17. $this->upload = $upload;
  18. $this->download = $download;
  19. $this->total = $total;
  20. }
  21. public function via($notifiable)
  22. {
  23. return sysConfig('data_anomaly_notification');
  24. }
  25. public function toMail($notifiable)
  26. {
  27. return (new MailMessage)
  28. ->subject(trans('notification.data_anomaly'))
  29. ->line(trans('notification.data_anomaly_content', ['id' => $this->userId, 'upload' => $this->upload, 'download' => $this->download, 'total' => $this->total]));
  30. }
  31. public function toCustom($notifiable)
  32. {
  33. return [
  34. 'title' => trans('notification.data_anomaly'),
  35. 'content' => trans('notification.data_anomaly_content', ['id' => $this->userId, 'upload' => $this->upload, 'download' => $this->download, 'total' => $this->total]),
  36. ];
  37. }
  38. }