Beispiel #1
0
 /**
  * Finds the Temp model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Temp the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Temp::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #2
0
 public function search($params)
 {
     $query = Temp::find()->where(['usr' => $this->findModel()->usr]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'today' => $this->today]);
     $query->andFilterWhere(['like', 'temp', $this->temp])->andFilterWhere(['like', 'usr', $this->usr]);
     return $dataProvider;
 }
Beispiel #3
0
 public function actionSetCardio()
 {
     $request = Yii::$app->request;
     if (!($data = $request->post('json'))) {
         return $this->goHome();
     }
     $jsObj = json_decode($data, JSON_UNESCAPED_UNICODE);
     $today = date("Y-m-d H:i:s");
     $tempRecord = new Temp();
     $tempRecord->usr = $jsObj["usr"];
     if ($jsObj["temp"] > 0) {
         $tempRecord->temp = $jsObj["temp"];
     }
     $tempRecord->pulse = $jsObj["pulse"];
     $tempRecord->pulseAvg = $jsObj["pulseAvg"];
     $tempRecord->today = $today;
     $tempRecord->save();
     echo "success";
     return;
 }