Delete the file and corresponding mappings.

@param \cmsgears\core\common\models\resources\File $model
@param array $config
@return boolean
192566
public function delete( $model, $config = [] ) {

		$admin = isset( $config[ 'admin' ] ) ? $config[ 'admin' ] : false;

		if( isset( $model ) ) {

			// Only admin is authorised to delete a shared file using file browser.
			if( $admin || !$model->shared ) {

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

				// Delete from disk
				$model->clearDisk();

				// Delete model
				return parent::delete( $model, $config );
			}
		}

		return false;
	}
137021
public function deleteFiles(Model $model, $id, array $filter = array(), $isDelete = false) {
        $columns = $this->_columns[$model->alias];
        $data = $this->_doFind($model, array($model->alias . '.' . $model->primaryKey => $id));

        if (empty($data[$model->alias])) {
            return false;
        }

        // Set data in case $this->data is used in callbacks
        $model->set($data);

        $save = array();

        foreach ($data[$model->alias] as $column => $value) {
            if (empty($columns[$column]) || empty($value)) {
                continue;
            } else if ($filter && !in_array($column, $filter)) {
                continue;
            }

            if ($this->_deleteFile($model, $columns[$column], $value, $column)) {
                $save[$column] = '';

                // Reset meta data also
                foreach ($this->settings[$model->alias][$columns[$column]]['metaColumns'] as $metaKey => $fieldKey) {
                    $save[$fieldKey] = '';
                }
            }
        }

        // Set the fields to empty
        if ($save && !$isDelete) {
            $model->id = $id;
            $model->save($save, array(
                'validate' => false,
                'callbacks' => false,
                'fieldList' => array_keys($save)
            ));
        }

        return true;
    }
935493
private function checkDiffFilesWithConfig(Config $config, array $file_list = [])
    {
        $files_to_scan = [];

        foreach ($file_list as $file_path) {
            if (!$this->file_provider->fileExists($file_path)) {
                continue;
            }

            if (!$config->isInProjectDirs($file_path)) {
                if ($this->debug_output) {
                    echo 'skipping ' . $file_path . "\n";
                }

                continue;
            }

            $files_to_scan[$file_path] = $file_path;
        }

        $this->codebase->addFilesToAnalyze($files_to_scan);
    }
681597
public function delete( $model, $config = [] ) {

		if( empty( $model ) ) {

			return false;
		}

		// Delete Items
		$this->fileService->deleteMultiple( $model->files );

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

		// Delete model
		return parent::delete( $model, $config );
	}
1186981
public function delete( $model, $config = [] ) {

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

		// Delete Slider
		return parent::delete( $model, $config );
	}
574586
protected function deleteModel(Model $model)
    {
        $strategy = $this->getModelInformation()->deleteStrategy();

        if ( ! $strategy) {
            return $model->delete();
        }

        /** @var DeleteStrategyFactoryInterface $factory */
        $factory = app(DeleteStrategyFactoryInterface::class);
        $strategy = $factory->make($strategy);

        return $strategy->delete($model);
    }
1039272
private function deleteFile($key)
    {
        $file = $this->findFile($key);
        if ($file === false) {
            return false; // error
        }

        if ($file === 0) {
            return true; // nothing found
        }

        return unlink($file);
    }
1118071
public function creating(Model $model)
    {
        if (request()->hasFile('name')) {
            // delete prev image
            $file = $this->fileUploader->handle(request()->file('name'));
            $model->name = $file['filename'];
            $model->fill(Arr::except($file, 'filename'));
        } else {
            if ($model->type !== 'f') {
                return false;
            }
        }
    }
911122
protected function _deleteFile($filename) {
        $ini = Zend_Registry::get('config');
        $uploadPath = $ini->app->uploadsDirectory;
        $uploadPath = rtrim($uploadPath, '/\\').DIRECTORY_SEPARATOR;
        $filePath   = $uploadPath.$filename;
        if (file_exists($filePath) && is_file($filePath)) {
            unlink($filePath);
        }
    }
48862
public function renderForm(Model $model, array $config)
    {
        $form = null;
        foreach ($config as $attribute => $options) {
            $form .= $this->renderField($model, $attribute, $options);
        }

        return $form;
    }
1346217
private function deleteFile($file = null) {
        // no file
        if(!$file || is_array($file))
            return false;

        // get a file and delete it
        $file = new File($this->_config['root'] . trim(str_replace('/', DS, $file), DS));
        if($file->exists())
            return $file->delete();

        // nothing found
        return false;
    }
180917
public function remove(Builder $builder, Model $model)
	{
		$column = $model->getQualifiedDeletedAtColumn();

		$query = $builder->getQuery();

		$query->wheres = collect($query->wheres)->reject(function($where) use ($column)
		{
			return $this->isSoftDeleteConstraint($where, $column);
		})->values()->all();
	}
848744
public function delete($filename)
    {
        $this->initialize();

        try {
            $file = $this->matcher->getFile($filename);
        } catch (FileNotFoundException $e) {
            return;
        }

        foreach ($this->files as $key => $item) {
            if ($item->getFullPath() === $file->getFullPath()) {
                unset($this->files[$key]);
                $this->files = array_values($this->files); // normalize indexes
                $this->persist();
                break;
            }
        }
    }
22857
public function removeFile( $fileName )
	{
		if( !$this->numFiles )
			return FALSE;
		foreach( $this->files as $key => $information )
		{
			if( $information['name'] !== $fileName )
				continue;
			$this->numFiles--;
			unset( $this->files[$key] );
			return TRUE;
		}
	}
818024
public static function writeToDisk(Config $config) : void
    {
        $filePath = $config->getPath();
        $file     = new Json($filePath);
        $file->write($config->getJsonData());
    }
819776
public function delete( $model, $config = [] ) {

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

		// Delete model
		return parent::delete( $model, $config );
	}
210183
public function create( $model, $config = [] ) {

		// model class
		$modelClass = static::$modelClass;

		// Default visibility
		if( !isset( $model->visibility ) ) {

			$model->visibility = File::VISIBILITY_PUBLIC;
		}

		$model->siteId	= isset( $config[ 'siteId' ] ) ? $config[ 'siteId' ] : Yii::$app->core->siteId;

		// Default sharing
		if( !isset( $model->shared ) ) {

			$model->shared = false;
		}

		// Create File
		$model->save();

		// Return File
		return $model;
	}