public function actionSwitchShow($id)
    {
        $category = Category::findOne($id);
        if (!empty($category)) {
            $this->trigger(self::EVENT_BEFORE_EDIT_CATEGORY);
            $category->show = !$category->show;
            $category->save();
            $this->trigger(self::EVENT_AFTER_EDIT_CATEGORY,
                new CategoryEvent(['id' => $id]));
            if (\Yii::$app->request->isAjax) {
                return $category->show;
            }
            return $this->actionIndex();
        } else throw new NotFoundHttpException();
    }
public function actionSwitchShow($id)
    {
        $category = Category::findOne($id);
        if (!empty($category)) {
            $this->trigger(self::EVENT_BEFORE_EDIT_CATEGORY);
            $category->show = !$category->show;
            $category->save();
            $this->trigger(self::EVENT_AFTER_EDIT_CATEGORY,
                new CategoryEvent(['id' => $id]));
            if (\Yii::$app->request->isAjax) {
                return $category->show;
            }
            return $this->actionIndex();
        } else throw new NotFoundHttpException();
    }
public function actionSwitchShow ( $ id ) { $ category = Category :: findOne ( $ id ) ; if ( ! empty ( $ category ) ) { $ this -> trigger ( self :: EVENT_BEFORE_EDIT_CATEGORY ) ; $ category -> show = ! $ category -> show ; $ category -> save ( ) ; $ this -> trigger ( self :: EVENT_AFTER_EDIT_CATEGORY , new CategoryEvent ( [ 'id' => $ id ] ) ) ; if ( \ Yii :: $ app -> request -> isAjax ) { return $ category -> show ; } return $ this -> actionIndex ( ) ; } else throw new NotFoundHttpException ( ) ; }
Shows or hides category

@param integer $id
@return mixed
@throws NotFoundHttpException
Shows or hides category