/**
  * Creates a new BalanceItem model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new BalanceItem();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         $result = $model->initAccounts();
         if ($result) {
             var_dump($result);
             die;
         }
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Example #2
0
 private function createBalanceItem($step)
 {
     if ($step->type_id > '') {
         $model = new BalanceItem();
         $model->name = $step->title;
         $model->balance_type_id = $step->type_id;
         if ($model->save()) {
             $result = $model->initAccounts();
             if ($result) {
                 $step->error = Json::encode($result);
                 return false;
             }
         } else {
             $step->error = Json::encode($model->errors);
             return false;
         }
     }
     return true;
 }