closeTicket.php 1019 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App\Mail;
  3. use App\Models\NotificationLog;
  4. use Exception;
  5. use Illuminate\Bus\Queueable;
  6. use Illuminate\Contracts\Queue\ShouldQueue;
  7. use Illuminate\Mail\Mailable;
  8. use Illuminate\Queue\SerializesModels;
  9. class closeTicket extends Mailable implements ShouldQueue
  10. {
  11. use Queueable;
  12. use SerializesModels;
  13. protected $id; // 邮件记录ID
  14. protected $title; // 工单标题
  15. protected $content; // 工单内容
  16. public function __construct($id, $title, $content)
  17. {
  18. $this->id = $id;
  19. $this->title = $title;
  20. $this->content = $content;
  21. }
  22. public function build(): closeTicket
  23. {
  24. return $this->view('emails.closeTicket')->subject('工单关闭提醒')->with([
  25. 'title' => $this->title,
  26. 'content' => $this->content,
  27. ]);
  28. }
  29. // 发件失败处理
  30. public function failed(Exception $e): void
  31. {
  32. NotificationLog::whereId($this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
  33. }
  34. }