Change parent of subordinate employees

@param array $data Data to change parent
@return bool Success
343750
protected function _changeParentInfo($data = null) {
		if (empty($data)) {
			return false;
		}

		$result = true;
		foreach ($data as $dataItem) {
			if (!isset($dataItem[$this->alias]['id']) && empty($dataItem[$this->alias]['id'])) {
				$result = false;
				continue;
			}
			$this->clear();
			$this->recursive = -1;
			$savedInfo = $this->read(null, $dataItem[$this->alias]['id']);
			$savedInfo[$this->alias] = $dataItem[$this->alias] + $savedInfo[$this->alias];
			if (!$this->save($savedInfo)) {
				$result = false;
			}
		}

		return $result;
	}
1311637
public function can_change_parent($newparentcat) {
        if (!has_capability('moodle/category:manage', $this->get_context())) {
            return false;
        }
        if (is_object($newparentcat)) {
            $newparentcat = self::get($newparentcat->id, IGNORE_MISSING);
        } else {
            $newparentcat = self::get((int)$newparentcat, IGNORE_MISSING);
        }
        if (!$newparentcat) {
            return false;
        }
        if ($newparentcat->id == $this->id || in_array($this->id, $newparentcat->get_parents())) {
            // Can not move to itself or it's own child.
            return false;
        }
        if ($newparentcat->id) {
            return has_capability('moodle/category:manage', context_coursecat::instance($newparentcat->id));
        } else {
            return has_capability('moodle/category:manage', context_system::instance());
        }
    }
483149
protected function _changeParent(Model $model, $id = null, $parentId = null) {
		$parentField = $this->_getBehaviorConfig($model, 'parent');
		if (empty($id) || ($parentField === null)) {
			return false;
		}

		$model->recursive = -1;
		$treeItem = $model->read(null, $id);
		if (empty($treeItem)) {
			return false;
		}

		$treeItem[$model->alias][$parentField] = $parentId;
		$result = (bool)$model->save($treeItem);

		return $result;
	}
1218684
public function setCustomer($data = [])
    {
        if (array_key_exists('name', $data)) {
            $this->setCustomerName($data['name']);
        }

        if (array_key_exists('email', $data)) {
            $this->setCustomerEmail($data['email']);
        }

        if (array_key_exists('number', $data)) {
            $this->setCustomerMsisdn($data['number']);
        }

        if (array_key_exists('phone', $data)) {
            $this->setCustomerMsisdn($data['phone']);
        }

        if (array_key_exists('msisdn', $data)) {
            $this->setCustomerMsisdn($data['msisdn']);
        }

        return $this;
    }
786884
public function selected( array $data )
    {
        if ( isset( $data[self::PROPERTIES_FIELD] ) &&
             is_string( $data[self::PROPERTIES_FIELD] ) )
        {
            $data[self::PROPERTIES_FIELD] =
                $this->parseProperties( $data[self::PROPERTIES_FIELD] );
        }

        return parent::selected( $data );
    }
1180789
public function setParentId($parentId)
    {
        return (is_string($this->parentAttribute) && !empty($this->parentAttribute)) ?
        $this->{$this->parentAttribute} = $parentId : null;
    }
993796
public function push($data = [])
    {
        $name = $this->_through;
        $this->_parent->{$name}->push($offset, $this->_item($data));
        return $this;
    }
912520
public function set_data( $data ) {

		foreach ( $this->child as $child ) {
			if ( method_exists( $child, 'set_data' ) ) {
				$child->set_data( $data );
			}
		}
		$this->data = $data;

	}
1312420
final protected function parseData(array $data, $parentId = 0)
    {
        $result = array();

        foreach ($data as $subArray) {
            $nested = array();

            if (isset($subArray[$this->childrenKey])) {
                // Recursive call
                $nested = $this->parseData($subArray[$this->childrenKey], $subArray[RelationBuilder::TREE_PARAM_ID]);
            }

            $result[] = array(
                RelationBuilder::TREE_PARAM_ID => $subArray[RelationBuilder::TREE_PARAM_ID], 
                RelationBuilder::TREE_PARAM_PARENT_ID => $parentId
            );

            $result = array_merge($result, $nested);
        }

        return $result;
    }
185141
public function replace($data) {

		if (! is_array($data)) {
			$data = $this->makeArray($data);
		}
		
		$this->_data = array_replace($this->_data, $data);
	}
276
public function create(array $data)
    {
        if (! array_key_exists('name', $data)) {
            $data['name'] = Str::slug($data['display_name']);
        }

        return parent::create($data);
    }
726654
protected function normalizeAclPresence($data)
    {
        if ( ! $data) {
            // @codeCoverageIgnoreStart
            return [];
            // @codeCoverageIgnoreEnd
        }

        if ($data instanceof AclPresenceInterface) {

            $data = [$data];

        } elseif (is_array($data) && ! Arr::isAssoc($data)) {

            $presences = [];

            foreach ($data as $nestedData) {

                if (is_array($nestedData)) {
                    $nestedData = new AclPresence($nestedData);
                }

                if ( ! ($nestedData instanceof AclPresenceInterface)) {
                    throw new UnexpectedValueException(
                        'ACL presence data from array provided by module is not an array or ACL presence instance'
                    );
                }

                $presences[] = $nestedData;
            }

            $data = $presences;

        } else {

            $data = [ new AclPresence($data) ];
        }

        /** @var AclPresenceInterface[] $data */

        // Now normalized to an array with one or more ACL presences.
        // Make sure the permission children are listed as simple strings.
        foreach ($data as $index => $presence) {

            $data[ $index ]->setPermissions($presence->permissions());
        }

        return $data;
    }
310626
public function updateUserGroup(array $data)
    {
        $result = $this->httpRaw(self::WECHAT_MEMBER_GROUP_UPDATE_PREFIX, $data, [
            'access_token' => $this->getAccessToken()
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'ok';
    }
204371
protected function applyPermission(array $data)
    {
        if (!($name = ArrayHelper::get($data, 'name'))) {
            return false;
        }
        if ($permission = $this->authManager->getPermission($name)) {
            return $permission;
        }
        $permission = $this->authManager->createPermission($name);
        $permission->description = ArrayHelper::get($data, 'description', '');
        $permission->ruleName    = ArrayHelper::get($data, 'ruleName',    '');
        if ($this->authManager->add($permission)) {
            return $permission;
        }
        return false;
    }
967383
public function create(array $data)
    {
        if (array_key_exists('password', $data)) {
            $data['password'] = bcrypt($data['password']);
        }

        return parent::create($data);
    }
1081089
public function populate($data = array())
    {
        if (isset($data['id']) && $data['id'] != null) {
            $this->id    = $data['id'];
        }

        if (isset($data['roleId']) && $data['roleId'] != null) {
            $this->roleId    = $data['roleId'];
        }
        if (isset($data['parent']) && $data['parent'] != null) {
            $this->parent    = $data['parent'];
        }
    }
292493
public function create($parentId, array $data)
    {
        $resource = $this->createPartialResourceUrlForList($parentId);
        $data = $this->client->post($resource, [$this->getResourceName() => $data]);

        return $this->fromArray(reset($data));
    }