src/helpers/Storage.php
public static function removeFile($fileId, $cleanup = false)
    {
        $model = StorageFile::find()->where(['id' => $fileId, 'is_deleted' => false])->one();
        if ($model) {
            if ($cleanup) {
                foreach (Yii::$app->storage->findImages(['file_id' => $fileId]) as $imageItem) {
                    StorageImage::findOne($imageItem->id)->delete();
                }
            }
            $response = $model->delete();
            Yii::$app->storage->flushArrays();
            return $response;
        }
    
        return true;
    }
public static function removeFile($fileId, $cleanup = false)
    {
        $model = StorageFile::find()->where(['id' => $fileId, 'is_deleted' => false])->one();
        if ($model) {
            if ($cleanup) {
                foreach (Yii::$app->storage->findImages(['file_id' => $fileId]) as $imageItem) {
                    StorageImage::findOne($imageItem->id)->delete();
                }
            }
            $response = $model->delete();
            Yii::$app->storage->flushArrays();
            return $response;
        }
    
        return true;
    }
public static function removeFile ( $ fileId , $ cleanup = false ) { $ model = StorageFile :: find ( ) -> where ( [ 'id' => $ fileId , 'is_deleted' => false ] ) -> one ( ) ; if ( $ model ) { if ( $ cleanup ) { foreach ( Yii :: $ app -> storage -> findImages ( [ 'file_id' => $ fileId ] ) as $ imageItem ) { StorageImage :: findOne ( $ imageItem -> id ) -> delete ( ) ; } } $ response = $ model -> delete ( ) ; Yii :: $ app -> storage -> flushArrays ( ) ; return $ response ; } return true ; }
Remove a file from the storage system.

@param integer $fileId The file id to delete
@param boolean $cleanup If cleanup is enabled, also all images will be deleted, this is by default turned off because
casual you want to remove the large source file but not the images where used in several tables and situations.
@return boolean
Remove a file from the storage system .