userTrafficAbnormalWarning.php 974 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace App\Mail;
  3. use App\Http\Models\EmailLog;
  4. use Illuminate\Bus\Queueable;
  5. use Illuminate\Mail\Mailable;
  6. use Illuminate\Queue\SerializesModels;
  7. use Illuminate\Contracts\Queue\ShouldQueue;
  8. class userTrafficAbnormalWarning extends Mailable implements ShouldQueue
  9. {
  10. use Queueable, SerializesModels;
  11. protected $id; // 邮件记录ID
  12. protected $title; // 邮件标题
  13. protected $content; // 邮件内容
  14. public function __construct($id, $title, $content)
  15. {
  16. $this->id = $id;
  17. $this->title = $title;
  18. $this->content = $content;
  19. }
  20. public function build()
  21. {
  22. return $this->view('emails.userTrafficAbnormalWarning')->subject('流量异常警告')->with([
  23. 'content' => $this->content
  24. ]);
  25. }
  26. // 发件失败处理
  27. public function failed(\Exception $e)
  28. {
  29. EmailLog::query()->where('id', $this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
  30. }
  31. }