public function actionCreate()
 {
     $model = new ProductCategory();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['product-category/view', 'id' => $model->id]);
     }
     return $this->render('create', compact('model'));
 }
 /**
  * Creates a new ProductCategory model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new ProductCategory();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => (string) $model->_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new ProductCategory model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new ProductCategory();
     $parentCategories = ProductCategory::findAll(['product_category_parent_id' => '']);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => (string) $model->_id]);
     } else {
         return $this->render('create', ['model' => $model, 'parentCategories' => $parentCategories]);
     }
 }
 /**
  * Creates a new ProductCategory model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new ProductCategory();
     $treeParents = TreeHelper::build($model->find()->addOrderBy('tree')->addOrderBy('lft')->all());
     if ($model->load(Yii::$app->request->post())) {
         if (empty($model->parent_id)) {
             $model->makeRoot();
         } else {
             $root = $model->findOne(['id' => $model->parent_id]);
             $model->appendTo($root);
         }
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model, 'treeParents' => $treeParents]);
     }
 }