public function signUpUser(NewUserRequest $request)
 {
     // Create a user logged him in, and create his profile.
     $new_user = new User();
     $new_user->username = $request->input('username');
     $new_user->nickname = $request->input('nickname');
     $new_user->password = Hash::make($request->input('password'));
     $new_user->save();
     // you can now access the id of the user.
     // create a default profile for the user.
     $this->createDefaultUserProfile($new_user);
     //login the user.
     Auth::login($new_user);
     return redirect('/home');
     //take to home page.
 }
Exemplo n.º 2
0
 public function postNewUser(NewUserRequest $request, User $users)
 {
     $role_id = $request->input('role');
     $new_users = $users->create(['username' => $request->input('username'), 'email' => Str::lower($request->input('email')), 'password' => bcrypt($request->input('password')), 'firstname' => Str::title($request->input('firstname')), 'lastname' => Str::title($request->input('lastname')), 'phone' => $request->input('phone'), 'role_id' => $role_id]);
     if ($new_users) {
         $role = Role::find($role_id);
         $new_users->attachRole($role);
         flash()->success('User Added Successfully!');
     } else {
         flash()->error('An error occurred, try adding the User again!');
     }
     return redirect()->route('user.list');
 }