public function actionToggleFileTag()
    {
        $tagId = Yii::$app->request->getBodyParam('tagId');
        $fileId = Yii::$app->request->getBodyParam('fileId');

        $file = StorageFile::findOne($fileId);

        if (!$file) {
            throw new NotFoundHttpException("Unable to find the given file to toggle the tag.");
        }
    
        $relation = TagRelation::find()->where(['table_name' => TaggableTrait::cleanBaseTableName(StorageFile::tableName()), 'pk_id' => $fileId, 'tag_id' => $tagId])->one();

        if ($relation) {
            $relation->delete();

            return $file->tags;
        }

        $model = new TagRelation();
        $model->table_name = TaggableTrait::cleanBaseTableName(StorageFile::tableName());
        $model->pk_id = $fileId;
        $model->tag_id = $tagId;

        $model->save();
        return $file->tags;
    }