Exemplo n.º 1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, UsersEditFormRequest $request)
 {
     $user = $this->user->find($id);
     if (!$request->has("password")) {
         $input = $request->only('email', 'first_name', 'last_name');
         $user->fill($input)->save();
         return redirect()->route('profiles.edit', $user->id)->withFlashMessage('User has been updated successfully!');
     } else {
         $input = $request->only('email', 'first_name', 'last_name', 'password');
         $user->fill($input);
         $user->password = \Hash::make($request->input('password'));
         $user->save();
         return redirect()->route('profiles.edit', $user->id)->with('success', 'User (and password) has been updated successfully!');
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, UsersEditFormRequest $request)
 {
     // $user = User::findOrFail($id);
     $user = $this->user->find($id);
     if (!$request->has("password")) {
         $input = $request->only('email', 'first_name', 'last_name');
         //$this->usersEditForm->excludeUserId($user->id)->validate($input);
         $user->fill($input)->save();
         return redirect()->route('profiles.edit', $user->id)->withFlashMessage('User has been updated successfully!');
     } else {
         $input = $request->only('email', 'first_name', 'last_name', 'password');
         //$this->usersEditForm->excludeUserId($user->id)->validate($input);
         // $input = array_except($input, ['password_confirmation']);
         $user->fill($input)->save();
         $user->save();
         return redirect()->route('profiles.edit', $user->id)->withFlashMessage('User (and password) has been updated successfully!');
     }
 }