public function update($id, UserUpdateRequest $request) { $user = $this->userRepository->find($id); if (empty($user)) { abort(404); } $this->userRepository->update($user, $request->all()); return redirect()->action('Admin\\UserController@show', [$id])->with('message-success', \Lang::get('admin.messages.general.update_success')); }
/** * * Handles the validation process of an user * * @param User $user * @param $type * @param $code * @return data */ public function validate(User $user, $type, $code) { //Existence $code = $this->confirmationRepository->getByConfirmationCode($code); if ($code == null) { switch ($type) { case 'mail': $this->dataReturn('not-found-mail'); break; case 'phone': $this->dataReturn('not-found-phone'); break; } return $this->data; } //Tests $user_test = $code->user_id == $user->id; $type_test = $code->type == $type; $expiration_test = Carbon::parse($code->created_at)->addHour(2)->isPast(); //Actions if ($expiration_test) { $this->dataReturn('expired'); } else { if ($user_test && $type_test) { $this->userRepository->update($user->id, ["profile" => ["{$type}_confirmed" => true]]); $this->dataReturn('success'); } else { $this->userRepository->update($user->id, ["profile" => ["{$type}_confirmed" => false]]); $this->dataReturn('failed'); } } $this->confirmationRepository->clear($user, $type); return $this->data; }
/** * Update the profile of the authenticated user * * @param OrganizationRequest|UserProfileRequest $request * @return Response */ public function update(OrganizationRequest $request) { $this->organization = Organization::findOrFail($this->organization->id); $this->organization->update($request->all()); $this->organization->save(); Flash::success(Lang::get('organization.update-success')); return redirect(action('OrganizationController@edit')); }