/**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $sensor = new Sensor();
     $sensor->sensor = $request->sensor;
     $sensor->value = $request->value;
     $sensor->latitude = $request->latitude;
     $sensor->longitude = $request->longitude;
     $sensor->element = $request->element;
     $sensor->save();
     return $sensor;
 }
示例#2
0
                $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);
});
//add sensor to sensingDevice
Route::get('device/access/{id}', function ($id) {
    $DeviceBaseId = DB::table('sensingdevice')->where('device_id', $id)->value('id');
    $deviceA = new Sensor();
    $deviceA->sensingDevice_id = $DeviceBaseId;
    $deviceA->name = "basic package";
    $deviceA->save();
});
Route::get('test', function () {
    echo url();
});
//delete sensor