App\Repositories\Frontend\Access\User\UserRepository::updateProfile PHP Méthode

updateProfile() public méthode

public updateProfile ( $id, $input ) : mixed
$id
$input
Résultat mixed
    public function updateProfile($id, $input)
    {
        $user = parent::find($id);
        $user->name = $input['name'];
        if ($user->canChangeEmail()) {
            //Address is not current address
            if ($user->email != $input['email']) {
                //Emails have to be unique
                if ($this->findByEmail($input['email'])) {
                    throw new GeneralException(trans('exceptions.frontend.auth.email_taken'));
                }
                $user->email = $input['email'];
            }
        }
        return parent::save($user);
    }

Usage Example

 /**
  * @param UpdateProfileRequest $request
  * @return mixed
  */
 public function update(UpdateProfileRequest $request)
 {
     $this->user->updateProfile(access()->id(), $request->all());
     return redirect()->route('frontend.user.account')->withFlashSuccess(trans('strings.frontend.user.profile_updated'));
 }