public function actionCreate() { $result = 0; if (Yii::$app->request->isPost && ($model = ProductFollowing::create(Yii::$app->request->post()))) { if ($model->hasErrors()) { $result = json_encode($model->getErrors()); } else { $result = 1; } } return $result; }