userExpireWarningToday.php 817 B

1234567891011121314151617181920212223242526272829303132333435363738
  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 userExpireWarningToday extends Mailable implements ShouldQueue
  10. {
  11. use Queueable;
  12. use SerializesModels;
  13. protected $id; // 邮件记录ID
  14. public function __construct($id)
  15. {
  16. $this->id = $id;
  17. }
  18. public function build(): userExpireWarningToday
  19. {
  20. return $this->view('emails.userExpireWarningToday')->subject('账号过期提醒');
  21. }
  22. // 发件失败处理
  23. public function failed(Exception $e): void
  24. {
  25. NotificationLog::whereId($this->id)->update(
  26. ['status' => -1, 'error' => $e->getMessage()]
  27. );
  28. }
  29. }