/** * Creates a new Temp model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Temp(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
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; }