public function actionDelete($id)
    {
        $this->trigger(self::EVENT_BEFORE_DELETE_CATEGORY);

        $category = Category::findOne($id);
        if (($category->delete())) {
            Yii::$app->getSession()->setFlash('success', 'The category has been successfully removed');
            if (\Yii::$app->request->isAjax) {
                return true;
            }
            $this->trigger(self::EVENT_AFTER_DELETE_CATEGORY, new CategoryEvent(['id' => $id]));
        } else {
            Yii::$app->getSession()->setFlash('error', 'Error deleting category');
        }

        if (\Yii::$app->request->isAjax) {
            return false;
        }
        return $this->redirect(\Yii::$app->request->referrer);
    }