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 bootstrap($app) { Yii::setAlias('@understeam', dirname(dirname(__DIR__))); if (!isset(Yii::$app->i18n->translations['understeam/feedback'])) { Yii::$app->i18n->translations['understeam/feedback'] = ['class' => 'yii\\i18n\\PhpMessageSource', 'sourceLanguage' => 'en-US', 'basePath' => '@understeam/easyii-feedback/src/messages']; } try { Feedback::getTableSchema(); } catch (InvalidConfigException $e) { if (Yii::$app->request->get('install-understeam-feedback') === '1') { ob_start(); WebConsole::console()->runAction('migrate', ['migrationPath' => __DIR__ . '/migrations', 'migrationTable' => 'understeam_feedback_migration', 'interactive' => false]); echo "<h1>Table successfully created!</h1>"; echo "<p><a href=\"" . strtr(Yii::$app->request->url, ['install-understeam-feedback=1' => 'installed=1']) . "\">Continue!</a></p>"; Yii::$app->end(); } else { echo "<h1>Understeam feedback module is not installed yet!</h1>"; echo "<p><a href=\"?install-understeam-feedback=1\">Install now!</a></p>"; Yii::$app->end(); } } }
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')); }