예제 #1
0
 public function store(Request $request)
 {
     $rules = array('email' => 'required|unique:users', 'username' => 'required', 'password' => 'required|min:6', 'password-repeat' => 'required|same:password');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to('/')->withInput(Input::except('password', 'password-repeat'))->withErrors($validator);
     }
     User::create(array('name' => Input::get('username'), 'email' => Input::get('email'), 'password' => Hash::make(Input::get('password'))));
     $credenciais = array('email' => $request->input('email'), 'password' => $request->input('password'));
     if (Auth::attempt($credenciais)) {
         $request = null;
         return Redirect::intended('login/create');
     } else {
         return Redirect::to('login')->withInput();
     }
 }
예제 #2
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
 }