/** * Handle the event. * * @param UserRegistered $event * @return void */ public function handle(UserRegistered $event) { $user = $event->user; $confirmationToken = EmailConfirmation::where('email', $user->email)->first(); if ($confirmationToken) { $confirmationToken = $confirmationToken->token; $urlConfirmation = env('APP_URL') . '/confirm?email=' . $user->email . '&token=' . $confirmationToken; $data = ['firstName' => $user->name, 'urlConfirmation' => $urlConfirmation]; Mail::queue('emails.welcome', $data, function ($message) use($user) { $message->from('*****@*****.**', 'I Heart Reading'); $message->to($user->email); }); } }
/** * Handle the event. * * @param UserConfirmed $event * @return void */ public function handle(UserConfirmed $event) { $email = $event->email; EmailConfirmation::where('email', $email)->first()->delete(); User::where('email', $email)->update(['confirmed' => true]); }
/** * Handle the event. * * @param UserRegistered $event * @return void */ public function handle(UserRegistered $event) { $token = str_random(30); $email = $event->user->email; EmailConfirmation::create(['token' => $token, 'email' => $email]); }