public function edit($id) : Response
    {
        if ($user = $this->model->findFirst($this->userData->getId())) {
            $request = $this->request->getPut();

            if (empty($request)) {
                $request = $this->request->getJsonRawBody(true);
            }

            //clean pass
            if (array_key_exists('password', $request) && !empty($request['password'])) {
                $user->password = Users::passwordHash($request['password']);
                unset($request['password']);
            }

            //clean default company
            if (array_key_exists('default_company', $request)) {
                //@todo check if I belong to this company
                if ($company = Companies::findFirst($request['default_company'])) {
                    $user->default_company = $company->getId();
                    unset($request['default_company']);
                }
            }

            //update
            if ($user->update($request, $this->updateFields)) {
                $user->password = null;
                return $this->response($user);
            } else {
                //didnt work
                throw new Exception($user->getMessages()[0]);
            }
        } else {
            throw new Exception('Record not found');
        }
    }
public function edit($id) : Response
    {
        if ($user = $this->model->findFirst($this->userData->getId())) {
            $request = $this->request->getPut();

            if (empty($request)) {
                $request = $this->request->getJsonRawBody(true);
            }

            //clean pass
            if (array_key_exists('password', $request) && !empty($request['password'])) {
                $user->password = Users::passwordHash($request['password']);
                unset($request['password']);
            }

            //clean default company
            if (array_key_exists('default_company', $request)) {
                //@todo check if I belong to this company
                if ($company = Companies::findFirst($request['default_company'])) {
                    $user->default_company = $company->getId();
                    unset($request['default_company']);
                }
            }

            //update
            if ($user->update($request, $this->updateFields)) {
                $user->password = null;
                return $this->response($user);
            } else {
                //didnt work
                throw new Exception($user->getMessages()[0]);
            }
        } else {
            throw new Exception('Record not found');
        }
    }
public function edit ( $ id ) : Response { if ( $ user = $ this -> model -> findFirst ( $ this -> userData -> getId ( ) ) ) { $ request = $ this -> request -> getPut ( ) ; if ( empty ( $ request ) ) { $ request = $ this -> request -> getJsonRawBody ( true ) ; } //clean pass
 if ( array_key_exists ( 'password' , $ request ) && ! empty ( $ request [ 'password' ] ) ) { $ user -> password = Users :: passwordHash ( $ request [ 'password' ] ) ; unset ( $ request [ 'password' ] ) ; } //clean default company
 if ( array_key_exists ( 'default_company' , $ request ) ) { //@todo check if I belong to this company
 if ( $ company = Companies :: findFirst ( $ request [ 'default_company' ] ) ) { $ user -> default_company = $ company -> getId ( ) ; unset ( $ request [ 'default_company' ] ) ; } } //update
 if ( $ user -> update ( $ request , $ this -> updateFields ) ) { $ user -> password = null ; return $ this -> response ( $ user ) ; } else { //didnt work
 throw new Exception ( $ user -> getMessages ( ) [ 0 ] ) ; } } else { throw new Exception ( 'Record not found' ) ; } }
Update a User Info

@method PUT
@url /v1/users/{id}

@return Phalcon\Http\Response
Update a User Info