public function api_save($data) { $model = new FeedbackModel($data); if ($model->save()) { return ['result' => 'success']; } else { return ['result' => 'error', 'error' => $model->getErrors()]; } }
public function actionIndex() { $model = new FeedbackModel(); $request = Yii::$app->request; if ($model->load($request->post())) { $returnUrl = $model->save() ? $request->post('successUrl') : $request->post('errorUrl'); return $this->redirect($returnUrl); } else { return $this->redirect(Yii::$app->request->baseUrl); } }
public function actionIndex() { $model = new FeedbackModel(); $request = Yii::$app->request; $Saved = 0; if ($model->load($request->post())) { if ($model->save()) { //var_dump($model->getErrors()); $Saved = 1; } } return $this->render('index', array('model' => $model, 'Saved' => $Saved)); }
public function actionIndex() { $model = new Feedback(); if ($model->load(Yii::$app->request->post())) { if ($model->save()) { Yii::$app->session->setFlash(Feedback::FLASH_KEY, 'success'); } else { Yii::$app->session->setFlash(Feedback::FLASH_KEY, 'error'); } return $this->redirect(Yii::$app->request->referrer); } else { return $this->redirect(Yii::$app->request->baseUrl); } }
public function dbInstall() { $db = Yii::$app->db; $tableOptions = null; if ($db->driverName === 'mysql') { $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=MyISAM'; } $db->createCommand()->createTable(Feedback::tableName(), ['feedback_id' => 'pk', 'name' => Schema::TYPE_STRING . '(64) NOT NULL', 'email' => Schema::TYPE_STRING . '(128) NOT NULL', 'phone' => Schema::TYPE_STRING . '(64) DEFAULT NULL', 'title' => Schema::TYPE_STRING . '(128) DEFAULT NULL', 'text' => Schema::TYPE_TEXT . ' NOT NULL', 'answer_subject' => Schema::TYPE_STRING . '(128) DEFAULT NULL', 'answer_text' => Schema::TYPE_TEXT . ' DEFAULT NULL', 'time' => Schema::TYPE_INTEGER . " DEFAULT '0'", 'ip' => Schema::TYPE_STRING . '(16) NOT NULL', 'status' => Schema::TYPE_BOOLEAN . " DEFAULT '0'"], $tableOptions)->execute(); }
public function actionDelete($id) { if ($model = Feedback::findOne($id)) { $model->delete(); } else { $this->error = Yii::t('easyii', 'Not found'); } return $this->formatResponse(Yii::t('easyii/feedback', 'Feedback deleted')); }
public function down() { $this->dropTable(models\Admin::tableName()); $this->dropTable(models\LoginForm::tableName()); $this->dropTable(models\Module::tableName()); $this->dropTable(models\Photo::tableName()); $this->dropTable(models\Setting::tableName()); $this->dropTable(Carousel::tableName()); $this->dropTable(catalog\models\Category::tableName()); $this->dropTable(catalog\models\Item::tableName()); $this->dropTable(article\models\Category::tableName()); $this->dropTable(article\models\Item::tableName()); $this->dropTable(Feedback::tableName()); $this->dropTable(File::tableName()); $this->dropTable(gallery\models\Category::tableName()); $this->dropTable(Guestbook::tableName()); $this->dropTable(News::tableName()); $this->dropTable(Page::tableName()); $this->dropTable(Subscriber::tableName()); $this->dropTable(History::tableName()); $this->dropTable(Text::tableName()); }