/** * Finds the Language model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Language the loaded model * @throws NotFoundHttpException if the model cannot be found */ public function findModel($id) { if (($model = \lajax\translatemanager\models\Language::findOne($id)) !== null) { return $model; } else { throw new \yii\web\NotFoundHttpException('The requested page does not exist.'); } }
/** * Modifying the state of language. * @return Json */ public function run() { Yii::$app->response->format = Response::FORMAT_JSON; $language = Language::findOne(Yii::$app->request->post('language_id', '')); if ($language !== null) { $language->status = Yii::$app->request->post('status', Language::STATUS_BETA); if ($language->validate()) { $language->save(); } } return $language->getErrors(); }