/** * Execute the job. * * @return void */ public function handle() { $request = EmailChangeRequest::create(["user_id" => $this->user->id, "email" => $this->user->email, "new_email" => $this->email]); // Mail user Mail::queue('user.emails.update.email', ["user" => $this->user, "token" => $request->token], function ($message) { $message->to($this->user->email); $message->subject('Email change request.'); }); }
/** * Confirm's the user's email change request. * * @param $token * @return mixed */ public function changeEmailConfirm($token) { $request = EmailChangeRequest::where('token', $token); if ($request->exists()) { $change = $request->first(); Bus::dispatch(new ChangeEmailAddress($change->user(), $change->new_email)); Event::fire(new EmailUpdatedEvent($change->user())); $request->delete(); return true; } return false; }