closeTicket.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. [
  26. 'title' => $this->title,
  27. 'content' => $this->content,
  28. ]
  29. );
  30. }
  31. // 发件失败处理
  32. public function failed(Exception $e): void
  33. {
  34. NotificationLog::whereId($this->id)->update(
  35. ['status' => -1, 'error' => $e->getMessage()]
  36. );
  37. }
  38. }