activeUser.php 912 B

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