VerifyCode.php 1008 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace App\Mail;
  3. use Illuminate\Bus\Queueable;
  4. use Illuminate\Mail\Mailable;
  5. use Illuminate\Queue\SerializesModels;
  6. /**
  7. * 邮件验证码发送
  8. *
  9. */
  10. class VerifyCode extends Mailable
  11. {
  12. use Queueable, SerializesModels;
  13. /**
  14. * 创建一个新实例
  15. * @param Array $data 需要传输的数据
  16. * @param Array $options 邮件配置
  17. *
  18. *
  19. * @return void
  20. */
  21. public function __construct($data=[],$options=['views'=>''])
  22. {
  23. //进行赋值
  24. $this->data = $data;
  25. //进行赋值
  26. $this->options = $options;
  27. }
  28. /**
  29. * Build the message.
  30. *
  31. * @return $this
  32. */
  33. public function build()
  34. {
  35. // 如果有视图,获取视图
  36. if( !empty($this->options['views']) ) $this->view($this->options['views']);
  37. // 如果有数据,分配数据
  38. if( !empty($this->data) ) $this->with($this->data);
  39. // 返回自己
  40. return $this;
  41. }
  42. }