コード例 #1
0
ファイル: SystemController.php プロジェクト: shuangjie/galaxy
 /**
  * Finds the Setting model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Setting the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     $setting = Yii::createObject(Setting::className());
     if (($model = $setting::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #2
0
 /**
  * Creates a new Setting model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = Yii::createObject(Setting::className());
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->setting_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }