Exemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //return $request->all();
     // Grab the inputs and validate them
     /*        $new_user = $request->only(
                 'email', 'name', 'password', 'password_confirmation', 'superUser'
             );*/
     //$validation = new SeatUserRegisterValidator;
     // Should the form validation pass, continue to attempt to add this user
     //if ($validation->passes()) {
     // Because users are soft deleted, we need to check if if
     // it doesnt actually exist first.
     /*            $user = User::withTrashed()
                   ->where('email', $request->email)
                   ->orWhere('username', $request->username)
                   ->first();*/
     // If we found the user, restore it and set the
     // new values found in the post
     /*            if($user)
                     $user->restore();
                 else*/
     $user = new User();
     // With the user object ready, work the update
     $user->email = $request->email;
     $user->name = $request->name;
     $user->password = bcrypt($request->password);
     if (isset($request->superUser)) {
         $user->superUser = true;
     }
     $user->save();
     flash()->success('Success', 'Added user ' . $request->name . ' to the system');
     return redirect()->action('UserController@index');
     //} else {
     //
     //     return redirect()->back()
     //             ->withInput()
     //              ->withErrors($validation->errors);
     //       }
 }