Interal mechanism to remove Parents from Skill

@param Skill $model
@param mixed $data
487463
protected function doRemoveParents(Skill $model, $data) {
		$errors = [];
		foreach ($data as $entry) {
			if (!isset($entry['id'])) {
				$errors[] = 'Missing id for Skill';
			} else {
				$related = SkillQuery::create()->findOneById($entry['id']);
				$model->removeSkillRelatedByDependencyId($related);
			}
		}

		if (count($errors) > 0) {
			return new ErrorsException($errors);
		}
	}
1186981
public function delete( $model, $config = [] ) {

		// Clear all related slides
		$this->slideService->deleteBySliderId( $model->id );

		// Delete Slider
		return parent::delete( $model, $config );
	}
1327205
protected function doRemoveObjects(Sport $model, $data) {
		$errors = [];
		foreach ($data as $entry) {
			if (!isset($entry['id'])) {
				$errors[] = 'Missing id for Object';
			} else {
				$related = ObjectQuery::create()->findOneById($entry['id']);
				$model->removeObject($related);
			}
		}

		if (count($errors) > 0) {
			return new ErrorsException($errors);
		}
	}
929820
protected function doUpdateRootSkills(Kstruktur $model, $data) {
		// remove all relationships before
		SkillQuery::create()->filterByKstrukturRoot($model)->delete();

		// add them
		$errors = [];
		foreach ($data as $entry) {
			if (!isset($entry['id'])) {
				$errors[] = 'Missing id for Skill';
			} else {
				$related = SkillQuery::create()->findOneById($entry['id']);
				$model->addRootSkill($related);
			}
		}

		if (count($errors) > 0) {
			throw new ErrorsException($errors);
		}
	}
447681
protected function doUpdateChildren(Skill $model, $data) {
		// remove all relationships before
		SkillDependencyQuery::create()->filterBySkillRelatedByParentId($model)->delete();

		// add them
		$errors = [];
		foreach ($data as $entry) {
			if (!isset($entry['id'])) {
				$errors[] = 'Missing id for Skill';
			} else {
				$related = SkillQuery::create()->findOneById($entry['id']);
				$model->addSkillRelatedByDependencyId($related);
			}
		}

		if (count($errors) > 0) {
			throw new ErrorsException($errors);
		}
	}
903182
protected function doSetSportId(Skill $model, $relatedId) {
		if ($model->getSportId() !== $relatedId) {
			$model->setSportId($relatedId);

			return true;
		}

		return false;
	}
202876
protected function doRemoveFeaturedSkills(Video $model, $data) {
		$errors = [];
		foreach ($data as $entry) {
			if (!isset($entry['id'])) {
				$errors[] = 'Missing id for Skill';
			} else {
				$related = SkillQuery::create()->findOneById($entry['id']);
				$model->removeFeaturedSkill($related);
			}
		}

		if (count($errors) > 0) {
			return new ErrorsException($errors);
		}
	}
1353995
public function remove(Builder $builder, Model $model)
    {
        $query      = $builder->getQuery();
        $columns    = $model->getQualifiedOrderByColumns();

        foreach ($columns as $column => $direction) {

            foreach ((array) $query->orders as $key => $order) {

                if ($order['column'] == $column) {
                    $this->removeOrderBy($query, $key);
                }
            }
        }
    }
69336
protected function doAddKstrukturs(Skill $model, $data) {
		$errors = [];
		foreach ($data as $entry) {
			if (!isset($entry['id'])) {
				$errors[] = 'Missing id for Kstruktur';
			} else {
				$related = KstrukturQuery::create()->findOneById($entry['id']);
				$model->addKstruktur($related);
			}
		}

		if (count($errors) > 0) {
			return new ErrorsException($errors);
		}
	}
606905
protected function doAddParts(Skill $model, $data) {
		$errors = [];
		foreach ($data as $entry) {
			if (!isset($entry['id'])) {
				$errors[] = 'Missing id for Skill';
			} else {
				$related = SkillQuery::create()->findOneById($entry['id']);
				$model->addSkillRelatedByPartId($related);
			}
		}

		if (count($errors) > 0) {
			return new ErrorsException($errors);
		}
	}
1327865
public function removeSkill(ChildSkill $skill)
    {
        if ($this->getSkills()->contains($skill)) { $skillReference = new ChildSkillReference();

            $skillReference->setSkill($skill);
            if ($skill->isReferencesLoaded()) {
                //remove the back reference if available
                $skill->getReferences()->removeObject($this);
            }

            $skillReference->setReference($this);
            $this->removeSkillReference(clone $skillReference);
            $skillReference->clear();

            $this->collSkills->remove($this->collSkills->search($skill));

            if (null === $this->skillsScheduledForDeletion) {
                $this->skillsScheduledForDeletion = clone $this->collSkills;
                $this->skillsScheduledForDeletion->clear();
            }

            $this->skillsScheduledForDeletion->push($skill);
        }


        return $this;
    }
1149729
protected function doUpdateSkills(Sport $model, $data) {
		// remove all relationships before
		SkillQuery::create()->filterBySport($model)->delete();

		// add them
		$errors = [];
		foreach ($data as $entry) {
			if (!isset($entry['id'])) {
				$errors[] = 'Missing id for Skill';
			} else {
				$related = SkillQuery::create()->findOneById($entry['id']);
				$model->addSkill($related);
			}
		}

		if (count($errors) > 0) {
			throw new ErrorsException($errors);
		}
	}
1282794
public function delete( $model, $config = [] ) {

		// Delete mapping
		Yii::$app->factory->get( 'modelObjectService' )->deleteByParent( $model->id, static::$parentType );

		// Delete model
		return parent::delete( $model, $config );
	}
848871
protected function doAddPictures(Skill $model, $data) {
		$errors = [];
		foreach ($data as $entry) {
			if (!isset($entry['id'])) {
				$errors[] = 'Missing id for Picture';
			} else {
				$related = PictureQuery::create()->findOneById($entry['id']);
				$model->addPicture($related);
			}
		}

		if (count($errors) > 0) {
			return new ErrorsException($errors);
		}
	}
499190
public function updateParents($id, $data) {
		// find
		$model = $this->get($id);

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

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

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

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

		return NotUpdated(['model' => $model]);
	}
1059693
protected function doUpdateFeaturedSkills(Video $model, $data) {
		// remove all relationships before
		SkillQuery::create()->filterByFeaturedVideo($model)->delete();

		// add them
		$errors = [];
		foreach ($data as $entry) {
			if (!isset($entry['id'])) {
				$errors[] = 'Missing id for Skill';
			} else {
				$related = SkillQuery::create()->findOneById($entry['id']);
				$model->addFeaturedSkill($related);
			}
		}

		if (count($errors) > 0) {
			throw new ErrorsException($errors);
		}
	}
116566
protected function doAddComposites(Skill $model, $data) {
		$errors = [];
		foreach ($data as $entry) {
			if (!isset($entry['id'])) {
				$errors[] = 'Missing id for Skill';
			} else {
				$related = SkillQuery::create()->findOneById($entry['id']);
				$model->addSkillRelatedByCompositeId($related);
			}
		}

		if (count($errors) > 0) {
			return new ErrorsException($errors);
		}
	}