/**
  * @param array $relationData
  * @param \Phalcon\Mvc\Model $model
  * @param string $relationName
  * @return mixed
  * @throws Exception
  */
 private function update(array $relationData, $model, $relationName)
 {
     if (empty($relationData['id'])) {
         throw new Exception('relation "' . $relationName . '" have need id for update operation.');
     }
     $id = intval($relationData['id']);
     $relation = $model->getModelsManager()->getRelationByAlias(get_class($model), $relationName);
     $relationClass = $relation->getReferencedModel();
     $modelRelation = $relationClass::findFirstById($id);
     if (!$modelRelation) {
         throw new Exception($relationClass . '::findFirstById, with id=' . $id . ' not found');
     }
     $modelRelation->assign($relationData);
     $this->securityManager->check(array('model' => $modelRelation, 'action' => CrudOperations::CREATE, 'modelName' => get_class($modelRelation), 'params' => $relationData));
     $this->logManager->setOldModel($modelRelation);
     $result = $modelRelation->save();
     if ($result) {
         $this->logManager->updateModel($modelRelation);
     }
     return $result;
 }