nodeCrashWarning.php 788 B

1234567891011121314151617181920212223242526272829303132
  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 nodeCrashWarning extends Mailable implements ShouldQueue {
  10. use Queueable, SerializesModels;
  11. protected $id; // 邮件记录ID
  12. public function __construct($id) {
  13. $this->id = $id;
  14. }
  15. public function build() {
  16. return $this->view('emails.nodeCrashWarning')->subject('节点阻断警告')->with([
  17. 'content' => NotificationLog::query()->whereId($this->id)->first()->content
  18. ]);
  19. }
  20. // 发件失败处理
  21. public function failed(Exception $e) {
  22. NotificationLog::query()->whereId($this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
  23. }
  24. }