auth = $auth; $this->middleware('guest', ['except' => 'getLogout']); } /** * Show the application registration form. * * @return Response */ public function getRegister() { return view('auth.register'); } /** * Handle a registration request for the application. * * @param Request $request * @return Response */ public function postRegister(Request $request) { $this->validate($request, [ 'name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|min:6|confirmed', ]); $user = User::forceCreate([ 'name' => $request->name, 'email' => $request->email, 'password' => bcrypt($request->password), ]); $this->auth->login($user); return redirect('/home'); } /** * Show the application login form. * * @return Response */ public function getLogin() { return view('auth.login'); } /** * Handle a login request to the application. * * @param Request $request * @return Response */ public function postLogin(Request $request) { $this->validate($request, [ 'email' => 'required', 'password' => 'required' ]); $credentials = $request->only('email', 'password'); if ($this->auth->attempt($credentials, $request->has('remember'))) { return redirect('/home'); } return redirect('/auth/login') ->withInput($request->only('email')) ->withErrors([ 'email' => 'These credentials do not match our records.', ]); } /** * Log the user out of the application. * * @return Response */ public function getLogout() { $this->auth->logout(); return redirect('/'); } }