activeUser.php 854 B

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