/** * @param $userId * @param PostEditProfileRequest $request * @param User $user * * @return \Illuminate\Http\RedirectResponse */ public function postEditProfile($userId, PostEditProfileRequest $request, User $user) { $input = $request->get('edit_profile'); foreach ($input as $key => $value) { if (empty(trim($value))) { unset($input[$key]); } if ($key == 'password') { $input[$key] = bcrypt($value); } } if ($user->find($userId)->update($input)) { return redirect()->route('general::user::getEditProfile', ['user_id' => $userId])->with('editProfileSuccess', true); } return redirect()->route('general::user::getEditProfile', ['user_id' => $userId])->with('editProfileFailure', false); }
/** * 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'])]); }