Advertisement
Guest User

Untitled

a guest
Oct 6th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. MAIL_DRIVER=smtp
  2. MAIL_HOST=smtp.mailtrap.io
  3. MAIL_PORT=2525
  4. MAIL_USERNAME=username
  5. MAIL_PASSWORD=password
  6. MAIL_ENCRYPTION=
  7.  
  8. public function register(Request $request)
  9. {
  10. $this->validator($request->all())->validate();
  11.  
  12. event(new Registered($user = $this->create($request->all())));
  13.  
  14. dispatch(new SendVerificationEmail($user));
  15. return view('verification');
  16.  
  17. // $this->guard()->login($user);
  18.  
  19. // return $this->registered($request, $user)
  20. // ?: redirect($this->redirectPath());
  21. }
  22.  
  23. public function verify($token)
  24.  
  25. {
  26. $user = User::where('email_token',$token)->first();
  27. $user->verified = 1;
  28. if($user->save())
  29. {
  30.  
  31. return view('emailconfirm',['user'=>$user]);
  32.  
  33. }
  34. }
  35.  
  36. class EmailVerification extends Mailable
  37. {
  38. use Queueable, SerializesModels;
  39.  
  40. /**
  41. * Create a new message instance.
  42. *
  43. * @return void
  44. */
  45.  
  46. protected $user;
  47. public function __construct($user)
  48. {
  49. //
  50. $this->user = $user;
  51. }
  52.  
  53. /**
  54. * Build the message.
  55. *
  56. * @return $this
  57. */
  58. public function build()
  59. {
  60. return $this->view('email.email')->with([
  61. 'email_token'=> $this->user->email_token,
  62. ]);
  63. }
  64. }
  65.  
  66. class SendVerificationEmail implements ShouldQueue
  67. {
  68. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  69.  
  70. /**
  71. * Create a new job instance.
  72. *
  73. * @return void
  74. */
  75.  
  76. protected $user;
  77. public function __construct($user)
  78. {
  79. //
  80. $this->user = $user;
  81.  
  82. }
  83.  
  84. /**
  85. * Execute the job.
  86. *
  87. * @return void
  88. */
  89. public function handle()
  90. {
  91. //
  92. $email = new EmailVerification($this->user);
  93. Mail::to($this->user->email)->send($email);
  94. }
  95. }
  96.  
  97. [2017-10-06 12:05:52] Processing: AppJobsSendVerificationEmail
  98. [2017-10-06 12:05:52] Processing: AppJobsSendVerificationEmail
  99. [2017-10-06 12:05:52] Processing: AppJobsSendVerificationEmail
  100. [2017-10-06 12:05:52] Processing: AppJobsSendVerificationEmail
  101. [2017-10-06 12:05:52] Processing: AppJobsSendVerificationEmail
  102. [2017-10-06 12:05:52] Processing: AppJobsSendVerificationEmail
  103. [2017-10-06 12:05:52] Processing: AppJobsSendVerificationEmail
  104. [2017-10-06 12:05:52] Processing: AppJobsSendVerificationEmail
  105. [2017-10-06 12:05:52] Processing: AppJobsSendVerificationEmail
  106. [2017-10-06 12:05:52] Processing: AppJobsSendVerificationEmail
  107. [2017-10-06 12:05:52] Processing: AppJobsSendVerificationEmail
  108. [2017-10-06 12:05:52] Processing: AppJobsSendVerificationEmail
  109. [2017-10-06 12:05:52] Processing: AppJobsSendVerificationEmail
  110. [2017-10-06 12:05:52] Processing: AppJobsSendVerificationEmail
  111. [2017-10-06 12:05:52] Processing: AppJobsSendVerificationEmail
  112. [2017-10-06 12:05:52] Processing: AppJobsSendVerificationEmail
  113. [2017-10-06 12:05:52] Processing: AppJobsSendVerificationEmail
  114. [2017-10-06 12:05:52] Processing: AppJobsSendVerificationEmail
  115. [2017-10-06 12:05:52] Processing: AppJobsSendVerificationEmail
  116. [2017-10-06 12:05:52] Processing: AppJobsSendVerificationEmail
  117. [2017-10-06 12:05:52] Processing: AppJobsSendVerificationEmail
  118. [2017-10-06 12:05:52] Processing: AppJobsSendVerificationEmail
  119. [2017-10-06 12:05:52] Processing: AppJobsSendVerificationEmail
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement