Update a resource

@param  mixed $id
@param  mixed $data
@return ApiProblem|mixed
765941
public function update($id, $data)
    {
        $data = $this->retrieveData($data);
        $updateData = [
            'methods'=> implode(',', $data['methods']),
        ];

        $this->table->update($updateData, ['id' => $id]);

        return $data;
    }
338397
public function update($id, array $data)
    {
        $todolist = $this->client->put(
            sprintf('buckets/%d/todolists/%d.json', $this->bucket, $id),
            [
                'json' => $data,
            ]
        );

        return new TodoList($this->response($todolist));
    }
1360719
public function update($id, $data)
    {
        $siteId = $this->getRequestSiteId();

        //ACCESS CHECK
        $sitePagesResource = $this->getSitePagesResourceId($siteId);
        if (!$this->isAllowed('pages', 'edit')
            && !$this->isAllowed(
                $sitePagesResource,
                'edit'
            )
        ) {
            $this->getResponse()->setStatusCode(Response::STATUS_CODE_401);

            return $this->getResponse();
        }

        $inputFilter = new SitePageUpdateInputFilter();

        $inputFilter->setData($data);

        if (!$inputFilter->isValid()) {
            return new ApiJsonModel(
                [],
                1,
                'Some values are missing or invalid for page update.',
                $inputFilter->getMessages()
            );
        }

        $data = $inputFilter->getValues();

        // <tracking>
        $data['modifiedByUserId'] = $this->getCurrentUserId();
        $data['modifiedReason'] = 'Update site in ' . get_class($this);

        $site = $this->getSite($siteId);

        if (empty($site)) {
            return new ApiJsonModel(
                null,
                1,
                "Site was not found with id {$siteId}."
            );
        }

        $page = $this->getPage($site, $id);

        $this->pageMutationService->updatePublishedVersionOfPage($this->getCurrentUser(), $page, $data);

        $apiResponse = new SitePageApiResponse($page);

        return new ApiJsonModel($apiResponse, 0, 'Success: Page updated.');
    }
746836
public function update($id, $data)
	{
		$this->getResponse()
			->setStatusCode(Response::STATUS_CODE_201);

		$returnData = '';
		$action = strtolower($this->params()->fromQuery('action'));
		$classifiedService = $this->getServiceLocator()->get('document.service.classified');
		
		switch($action) {
			case 'activation':
				try {
					$classifiedService->activate($id);		
					$returnData = array(
						'status' => 'success',
						'message' => 'Annuncio attivato con successo. Ti ricordiamo che potrebbero essere 
							necessarie alcune ore prima di poter visualizzare l\'annuncio.'
					);
				} catch(\Exception $e) {
					$this->getResponse()
						->setStatusCode(Response::STATUS_CODE_500);
					$returnData = array(
						'status' => 'danger',
						'message' => $e->getMessage()
					);
				}
				break;
			case 'disableenable':
				try {
					$classifiedService->enableDisable($id);		
					$returnData = array(
						'status' => 'success',
						'message' => 'Annuncio modificato con successo'
					);
				} catch(\Exception $e) {
					$this->getResponse()
						->setStatusCode(Response::STATUS_CODE_500);
					$returnData = array(
						'status' => 'danger',
						'message' => $e->getMessage()
					);
				}
				break;
			case 'touch':
				try {
					$classifiedService->touch($id);		
					$returnData = array(
						'status' => 'success',
						'message' => 'Annuncio aggiornato con successo'
					);
				} catch(\Exception $e) {
					$this->getResponse()
						->setStatusCode(Response::STATUS_CODE_500);
					$returnData = array(
						'status' => 'danger',
						'message' => $e->getMessage()
					);
				}
				break;
		}
		
		return new JsonModel($returnData);
	}
736171
public function updateMultiples($id, $data) {
		// find
		$model = $this->get($id);

		if ($model === null) {
			return new NotFound(['message' => 'Skill not found.']);
		}

		// pass update to internal logic
		try {
			$this->doUpdateMultiples($model, $data);
		} catch (ErrorsException $e) {
			return new NotValid(['errors' => $e->getErrors()]);
		}

		// save and dispatch events
		$this->dispatch(SkillEvent::PRE_MULTIPLES_UPDATE, $model, $data);
		$this->dispatch(SkillEvent::PRE_SAVE, $model, $data);
		$rows = $model->save();
		$this->dispatch(SkillEvent::POST_MULTIPLES_UPDATE, $model, $data);
		$this->dispatch(SkillEvent::POST_SAVE, $model, $data);

		if ($rows > 0) {
			return Updated(['model' => $model]);
		}

		return NotUpdated(['model' => $model]);
	}
958431
public function updateId($id, $data, $params=[], $filter=false) {
		return $this->driver->where("{$this->driver->id}=?", [$id])->update($data,$params);
	}
726687
public function requestToInterface($data,$id)
    {

        $appointmentInterface = $this->repository->update($id, $data);

        return $appointmentInterface;
    }
706973
public function updateNotification($id, array $data)
    {
        DB:: beginTransaction();
        try {
            $model         = $this->model->find($id);
            $model->active = array_get($data, 'active', 0);
            $model->save();
            $titles        = array_get($data, 'title', []);

            foreach ($titles as $langId => $title) {
                $content          = $model->contents()->getModel()->firstOrNew(['notification_id' => $id, 'lang_id' => $langId]);
                $content->content = $data['content'][$langId];
                $content->title   = $title;
                $content->subject = array_get($data, 'subject.' . $langId, '');

                $model->contents()->save($content);
            }
        } catch (Exception $ex) {
            DB::rollback();
            throw $ex;
        }
        DB::commit();
        return true;
    }
992415
public function update($id, array $data)
    {
        $data['modified'] = GC_TIME;
        return (bool) $this->db->update('module_gapi_credential', $data, array('credential_id' => $id));
    }
51671
public function update($id, array $data): bool
    {
        $bool = $this->repo->update($data, $id);
        if (false === $bool) {
            throw new CommodityCateException('商品分类没有修改成功', ExceptionCode::UPDATED_FAILURE);
        }

        return $bool;
    }
1137270
public function update($id, $data)
    {
        $modelName = $this->modelFullName;
        if($this->validate($data, $modelName::$rules))
        {
            $model = $modelName::find($id);
            if(!$model) throw new NotFoundException('There is no Resource with id = ' . $id . ' !');
            $model->update($data);
            return $model;
        }
    }
1338455
public function update($id, $data = [])
    {
        //  If we're deleting a post, skip all the rest
        if (!empty($data['is_deleted'])) {
            return parent::update($id, $data);
        }

        /**
         * Validate or generate a slug
         */
        $sSlug  = !empty($data['slug']) ? $data['slug'] : '';
        $sTitle = !empty($data['title']) ? $data['title'] : '';
        $sSlug  = $this->validateSlug($sSlug, $sTitle, $id);

        $oDb = Factory::service('Database');

        if (!$sSlug) {
            return false;
        } else {
            $oDb->set('slug', $sSlug);
        }

        //  Set data
        if (isset($data['blog_id'])) {
            $oDb->set('blog_id', $data['blog_id']);
        }

        if (isset($data['title'])) {
            $oDb->set('title', $data['title']);
        }

        if (isset($data['body'])) {
            $oDb->set('body', $data['body']);
        }

        if (isset($data['type'])) {
            $oDb->set('type', $data['type']);
        }

        if (isset($data['seo_title'])) {
            $oDb->set('seo_title', $data['title']);
        }

        if (isset($data['seo_description'])) {
            $oDb->set('seo_description', $data['seo_description']);
        }

        if (isset($data['seo_keywords'])) {
            $oDb->set('seo_keywords', $data['seo_keywords']);
        }

        if (isset($data['is_published'])) {
            $oDb->set('is_published', $data['is_published']);
        }

        if (isset($data['is_deleted'])) {
            $oDb->set('is_deleted', $data['is_deleted']);
        }

        //  Safety first!
        if (array_key_exists('image_id', $data)) {

            $imageId = (int) $data['image_id'];
            $imageId = !$imageId ? null : $imageId;

            $oDb->set('image_id', $imageId);
        }

        if (isset($data['video_url'])) {
            $oDb->set('video_url', $data['video_url']);
        }

        if (isset($data['audio_url'])) {
            $oDb->set('audio_url', $data['audio_url']);
        }

        //  Excerpt
        if (!empty($data['excerpt'])) {
            $oDb->set('excerpt', trim($data['excerpt']));
        } elseif (!empty($data['body'])) {
            $oDb->set('excerpt', word_limiter(trim(strip_tags($data['body']))), 50);
        }

        //  Publish date
        if (!empty($data['is_published']) && isset($data['published'])) {

            //  Published with date set
            $published = strtotime($data['published']);

            if ($published) {

                $published = toNailsDatetime($data['published']);

                $oDb->set('published', $published);

            } else {
                //  Failed, use NOW();
                $oDb->set('published', 'NOW()', false);
            }

        } else {

            //  No date set, use NOW();
            $oDb->set('published', 'NOW()', false);
        }

        if (isset($data['comments_enabled'])) {
            $oDb->set('comments_enabled', (bool) $data['comments_enabled']);
        }

        if (isset($data['comments_expire'])) {

            if (empty($data['comments_expire'])) {
                $oDb->set('comments_expire', null);
            } else {
                $oDb->set('comments_expire', $data['comments_expire']);
            }
        }

        $oDb->set('modified', 'NOW()', false);

        if (activeUser('id')) {

            $oDb->set('modified_by', activeUser('id'));
        }

        $oDb->where('id', $id);
        $oDb->update($this->table);

        // --------------------------------------------------------------------------

        //  Update/reset the post gallery if it's been defined
        if (isset($data['gallery'])) {

            //  Delete all categories
            $oDb->where('post_id', $id);
            $oDb->delete($this->tableImg);

            //  Recreate new ones
            if ($data['gallery']) {

                $galleryData = [];

                foreach ($data['gallery'] as $order => $imageId) {
                    if ((int) $imageId) {
                        $galleryData[] = ['post_id' => $id, 'image_id' => $imageId, 'order' => $order];
                    }
                }

                if ($galleryData) {

                    $oDb->insert_batch($this->tableImg, $galleryData);
                }
            }
        }

        // --------------------------------------------------------------------------

        //  Update/reset any categories/tags if any have been defined
        if (isset($data['categories'])) {

            //  Delete all categories
            $oDb->where('post_id', $id);
            $oDb->delete($this->tableCat);

            //  Recreate new ones
            if ($data['categories']) {

                $categoryData = [];

                foreach ($data['categories'] as $catId) {
                    $categoryData[] = ['post_id' => $id, 'category_id' => $catId];
                }

                $oDb->insert_batch($this->tableCat, $categoryData);
            }
        }

        if (isset($data['tags'])) {

            //  Delete all tags
            $oDb->where('post_id', $id);
            $oDb->delete($this->tableTag);

            //  Recreate new ones
            if ($data['tags']) {

                $tagData = [];

                foreach ($data['tags'] as $tagId) {
                    $tagData[] = ['post_id' => $id, 'tag_id' => $tagId];
                }

                $oDb->insert_batch($this->tableTag, $tagData);
            }
        }

        // --------------------------------------------------------------------------

        //  Add associations, if any
        if (isset($data['associations']) && is_array($data['associations'])) {

            //  Fetch association config
            $this->load->model('blog/blog_model');
            $associations = $this->blog_model->getAssociations();

            foreach ($data['associations'] as $index => $association) {

                if (!isset($associations[$index])) {

                    continue;
                }

                //  Clear old associations
                $oDb->where('post_id', $id);
                $oDb->delete($associations[$index]->target);

                //  Add new ones
                $associationData = [];

                foreach ($association as $associationId) {

                    $associationData[] = ['post_id' => $id, 'associated_id' => $associationId];
                }

                if ($associationData) {

                    $oDb->insert_batch($associations[$index]->target, $associationData);
                }
            }
        }

        // --------------------------------------------------------------------------

        return true;
    }
857275
public function update($id, array $data)
    {
        $istance = $this->getById($id);

        if (! $istance)
        {
            return false;
        }

        return $istance->update($data);
    }
1324834
public static function update(array $id = [], array $data = [], ClientInterface $client = null)
    {
        return (new RequestService($client))
            ->setResourceClass(static::class)
            ->setResourcePath(static::RESOURCE_PATH . "/:" . static::RESOURCE_ID)
            ->update($id, $data);
    }
714722
public function update($id, array $data)
    {
        $obj = $this->find($id);
        Event::fire('repository.updating', [$obj, $data]);
        $obj->update($data);
        return $obj;
    }
80137
public function updateReferences($id, $data) {
		// find
		$model = $this->get($id);

		if ($model === null) {
			return new NotFound(['message' => 'Skill not found.']);
		}

		// pass update to internal logic
		try {
			$this->doUpdateReferences($model, $data);
		} catch (ErrorsException $e) {
			return new NotValid(['errors' => $e->getErrors()]);
		}

		// save and dispatch events
		$this->dispatch(SkillEvent::PRE_REFERENCES_UPDATE, $model, $data);
		$this->dispatch(SkillEvent::PRE_SAVE, $model, $data);
		$rows = $model->save();
		$this->dispatch(SkillEvent::POST_REFERENCES_UPDATE, $model, $data);
		$this->dispatch(SkillEvent::POST_SAVE, $model, $data);

		if ($rows > 0) {
			return Updated(['model' => $model]);
		}

		return NotUpdated(['model' => $model]);
	}
347614
public function update($id, array $data)
    {
        $model = $this->find($id);

        if (!$model) {
            throw new RepositoryException("O item não solicitado não existe.");
        }

        $model->fill($data);

        $model->update();

        return $this->find($id);

    }