Delete the model by deleting related resources and mapper.

@param type $model
@param type $config
@return boolean
495044
public function delete( $model, $config = [] ) {

		$hard	= $config[ 'hard' ] ?? true;
		$notify = $config[ 'notify' ] ?? true;

		if( isset( $model ) ) {

			// Permanent Delete
			if( $hard ) {

				return $model->delete();
			}
			// Soft Delete - Useful for models using status to mark model as deleted, but keep for historic purpose.
			else {

				$interfaces = class_implements( static::class );

				if( isset( $interfaces[ 'cmsgears\core\common\services\interfaces\base\IApproval' ] ) ) {

					// Approval Trait
					return $this->softDeleteNotify( $model, $notify, $config );
				}
				else {

					return $this->softDelete( $model );
				}
			}
		}

		return false;
	}
1333770
public function update( $model, $config = [] ) {

		$attributes = isset( $config[ 'attributes' ] ) ? $config[ 'attributes' ] : [ 'code', 'iso', 'name' ];

		return parent::update( $model, [
			'attributes' => $attributes
		]);
	}
641715
public function delete(AbstractModel $model)
    {
        $collection = $this->getCollectionBy(
            $this->getModelConfiguration(get_class($model))
        );

        $this->setLastResult(
            $collection->remove($this->getModelDataAsArray($model))
        );

        return (bool) ($this->lastResult) ? $this->lastResult[self::RESULT_OK_INDEX] : false;
    }
276100
public function deleted(Model $model)
    {
        try {
            Croppa::delete('storage/'.$model->getOriginal('path'));
        } catch (Exception $e) {
            Log::error($e->getMessage());
        }
    }
649105
public function delete($object)
    {
        try {
            $this->dm->remove($object);
            $this->dm->flush();
        } catch (\Exception $e) {
            throw new ModelManagerException('', 0, $e);
        }
    }
666932
private function doCommitDelete(Model $model)
    {
        $this->dispatchLifecycleEvent(Events::preDelete, $model);

        $this->getPersisterFor($model->getType())->delete($model);
        $model->getState()->setDeleted();

        $this->dispatchLifecycleEvent(Events::postDelete, $model);
        return $model;
    }
479166
public function afterDelete(Model &$model)
    {
        /** @var \T4\Orm\Model $class */
        $class = get_class($model);
        $tableName = $class::getTableName();
        /** @var \T4\Dbal\Connection $connection */
        $connection = $class::getDbConnection();

        $query = (new Query())
            ->delete()
            ->table($tableName)
            ->where('__lft>:lft AND __rgt<:rgt')
            ->params([':lft' => $model->__lft, ':rgt' => $model->__rgt]);
        $connection->execute($query);

        $this->removeFromTreeByLftRgt($connection, $tableName, $model->__lft, $model->__rgt);

        $model->__lft = 0;
        $model->__rgt = 0;
        $model->__lvl = 0;
        $model->__prt = 0;
    }
378157
public function delete($con = null)
    {
        if (!method_exists($this->getModel(), 'delete')) {
            throw new PropelException('Cannot delete objects on a read-only model');
        }
        if (null === $con) {
            $con = $this->getConnection(Propel::CONNECTION_WRITE);
        }
        $con->beginTransaction();
        try {
            foreach ($this as $element) {
                $obj = $this->getWorkerObject();
                $obj->setDeleted(false);
                $obj->fromArray($element);
                $obj->delete($con);
            }
            $con->commit();
        } catch (Exception $e) {
            $con->rollback();
            throw $e;
        }
    }
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 );
	}
475019
public function update( $model, $config = [] ) {

		$existingModel = $this->getByNameType( $model->parentId, $model->parentType, $model->name, $model->type );

		// Create if it does not exist
		if( !isset( $existingModel ) ) {

			return $this->create( $model );
		}

		if( isset( $model->valueType ) ) {

			$existingModel->copyForUpdateFrom( $model, [ 'valueType', 'value' ] );
		}
		else {

			$existingModel->copyForUpdateFrom( $model, [ 'value' ] );
		}

		$existingModel->update();

		return $existingModel;
	}
138588
public function delete($model) {
        if ($model) {
            if (!is_array($model)) {
                $model = array($model);
            }
            return parent::delete($model);
        }
        else {
            return parent::delete();
        }
        return $this;
    }
342015
public function unlink(Model $model) {
        $this->getUnlinked()->flush()->append($model);

        $this->getPrimaryModel()->set($this->getPrimaryForeignKey(), null);

        return $this;
    }
627720
public function deleteModel($model)
    {
        // first remove any automatically created models
        /** @var $relationField ManyToManyField */
        foreach ($model->getMeta()->localManyToMany as $name => $relationField) {
            if ($relationField->relation->through->getMeta()->autoCreated) {
                $this->deleteModel($relationField->relation->through);
            }
        }
        $this->dropTable($model->getMeta()->getDbTable());
    }
451612
public function remove(Builder $builder, Model $model)
    {
        $query = $builder->getQuery();

        foreach ((array)$query->wheres as $key => $where)
        {
            if ($where['column'] === $model->getTypeKeyName())
            {
                unset($query->wheres[$key]);

                $query->wheres = array_values($query->wheres);
            }
        }
    }
752647
public function remove(Builder $builder, Model $model)
    {
        $table = $model->getVersionTable();

        $query = $builder->getQuery();

        $query->joins = collect($query->joins)->reject(function($join) use ($table)
        {
            return $this->isVersionJoinConstraint($join, $table);
        })->values()->all();
    }
1046357
public function deleted(Model $entity)
    {
        $data = [
            'database' => $this->getConnectionName(),
            'driver' => $this->getDriverName(),
        ];

        $this->dispatch($this->getDeleteTenantJob($entity, $data));

        return true;
    }
534348
public function delete( $model, $config = [] ) {

		$transaction = Yii::$app->db->beginTransaction();

		try {

			// Delete mappings
			Yii::$app->factory->get( 'modelFormService' )->deleteByModelId( $model->id );

			// Delete Fields
			Yii::$app->factory->get( 'formFieldService' )->deleteByFormId( $model->id );

			// Delete Model Content
			Yii::$app->factory->get( 'modelContentService' )->delete( $model->modelContent );

			$transaction->commit();

			// Delete model
			return parent::delete( $model, $config );
		}
		catch( Exception $e ) {

			$transaction->rollBack();

			throw new Exception( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_DEPENDENCY )  );
		}

		return false;
	}