toastr = $toastr; } /** * Forgot Username Form. * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function showForgotUsernameForm() { return view('auth.username'); } /** * Send Username Reminder. * * @return Illuminate\Http\RedirectResponse */ public function sendUsernameReminder(Request $request) { $email = $request->get('email'); $v = validator($request->all(), [ 'email' => 'required', ]); if ($v->fails()) { return redirect()->route('username.request') ->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options'])); } else { $user = User::where('email', '=', $email)->first(); if (empty($user)) { return redirect()->route('username.request') ->with($this->toastr->error('We could not find this email in our system!', 'Whoops!', ['options'])); } //send username reminder notification $user->notify(new UsernameReminder()); return redirect()->route('login') ->with($this->toastr->success('Your username has been sent to your email address!', 'Yay!', ['options'])); } } }