public function getHumidityWeeklySummary($id)
 {
     $humidityMax = Weekly::where('sensor_id', 'like', $id)->max('maxAirHumidity');
     $humidityMin = Weekly::where('sensor_id', 'like', $id)->min('minAirHumidity');
     $humidityAverage = Weekly::where('sensor_id', 'like', $id)->avg('avgAirHumidity');
     return response()->json(['humidityMin' => $humidityMin, 'humidityMax' => $humidityMax, 'humidityAverage' => $humidityAverage]);
 }
Beispiel #2
0
             $soilMoistureWeeklyMax = Weekly::where('sensor_id', '=', $SensorPrimaryKey)->max('maxSoilMoisture');
             $weeklyHistory = new WeeklyHistory();
             $weeklyHistory->minLight = $lightWeeklyMin;
             $weeklyHistory->avgLight = $lightWeeklyAverage;
             $weeklyHistory->maxLight = $lightWeeklyMax;
             $weeklyHistory->minTemperature = $temperatureWeeklyMin;
             $weeklyHistory->avgTemperature = $temperatureWeeklyAverage;
             $weeklyHistory->maxTemperature = $temperatureWeeklyMax;
             $weeklyHistory->minAirHumidity = $humidityWeeklyMin;
             $weeklyHistory->avgAirHumidity = $humidityWeeklyAverage;
             $weeklyHistory->maxAirHumidity = $humidityWeeklyMax;
             $weeklyHistory->minSoilMoisture = $soilMoistureWeeklyMin;
             $weeklyHistory->avgSoilMoisture = $soilMoistureWeeklyAverage;
             $weeklyHistory->maxSoilMoisture = $soilMoistureWeeklyMax;
             $Sensor->weeklyHistory()->save($weeklyHistory);
             Weekly::where('sensor_id', 'like', $SensorPrimaryKey)->delete();
         }
     }
 }
 $temperature = new Temperature();
 $soilMoisture = new SoilMoisture();
 $light = new Light();
 $humidity = new Humidity();
 $temperature->celsiusValue = $temp;
 $soilMoisture->soilValue = $soil;
 $light->luxValue = $lux;
 $humidity->humidityPercentage = $humid;
 $Sensor->temperature()->save($temperature);
 $Sensor->soilMoisture()->save($soilMoisture);
 $Sensor->light()->save($light);
 $Sensor->humidity()->save($humidity);