public function actionCreatecategory()
 {
     $model = new CatProd();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate()) {
             if ($model->save()) {
                 return $this->redirect('index');
             }
         }
     }
     return $this->renderAjax('createCategory', ['model' => $model]);
 }
Esempio n. 2
0
 public function tree()
 {
     $arrIN = array();
     // Model to array
     $arr = array();
     $query = CatProd::find()->where(['ssid' => helper::getSsid()])->orderBy('title')->all();
     // builds internall array
     foreach ($query as $item) {
         $arrIN[] = array('key' => $item->id, 'parent' => $item->self_id, 'title' => $item->title, 'folder' => true, 'href' => '#', 'target' => '_self');
     }
     foreach ($arrIN as $a) {
         $arr[$a['parent']][] = $a;
     }
     $tree = self::createTree($arr, $arr[0]);
     return $tree;
 }