backend/modules/product/controllers/CategoryController.php
/**
     * Lists all Category models.
     * @return mixed
     */
Lists all Category models.
@return mixed
Lists all Category models . @return mixed
public function actionIndex($id = NULL) {
        if (!empty($id)) {
            $model = $this->findModel($id);
        } else {
            $model = new Category();
        }
        if ($model->load(Yii::$app->request->post()) && Yii::$app->SetValues->Attributes($model) && $model->validate() && $model->save()) {
            if (!empty($id)) {
                Yii::$app->getSession()->setFlash('success', 'Updated Successfully');
            } else {
                Yii::$app->getSession()->setFlash('success', 'Created Successfully');
            }
            return $this->redirect(['index']);
        }
        $searchModel = new CategorySearch();
        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
        $dataProvider->query->orderBy(['id' => SORT_DESC]);
        return $this->render('index', [
                    'searchModel' => $searchModel,
                    'dataProvider' => $dataProvider,
                    'model' => $model,
        ]);
    }
public function actionIndex ( $ id = NULL ) { if ( ! empty ( $ id ) ) { $ model = $ this -> findModel ( $ id ) ; } else { $ model = new Category ( ) ; } if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && Yii :: $ app -> SetValues -> Attributes ( $ model ) && $ model -> validate ( ) && $ model -> save ( ) ) { if ( ! empty ( $ id ) ) { Yii :: $ app -> getSession ( ) -> setFlash ( 'success' , 'Updated Successfully' ) ; } else { Yii :: $ app -> getSession ( ) -> setFlash ( 'success' , 'Created Successfully' ) ; } return $ this -> redirect ( [ 'index' ] ) ; } $ searchModel = new CategorySearch ( ) ; $ dataProvider = $ searchModel -> search ( Yii :: $ app -> request -> queryParams ) ; $ dataProvider -> query -> orderBy ( [ 'id' => SORT_DESC ] ) ; return $ this -> render ( 'index' , [ 'searchModel' => $ searchModel , 'dataProvider' => $ dataProvider , 'model' => $ model , ] ) ; }
Lists all Category models.
Lists all Category models .