/**
  * Finds the Config model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Config the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Config::findOne($id)) !== null) {
         return $model;
     } else {
         throw new HttpException(404);
     }
 }
Example #2
0
 /**
  * Finds the Config model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Config the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Config::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function set($key, $value)
 {
     $model = Config::findOne(['param' => $key]);
     if (!$model) {
         throw new Exception('Undefined parameter ' . $key);
     }
     $this->data[$key] = $value;
     $model->value = $value;
     $model->save();
 }