public function testDeleteNotification()
 {
     $minMaxID = \App\MinMaxMonitor::where("sensor_id", "=", 6)->where("maxHumidityPercentage", "=", 20.0)->first()->id;
     $this->action('GET', 'notificationController@deleteNotification', array('id' => $minMaxID));
     $this->assertResponseStatus(200);
     $this->notSeeInDatabase("minmaxmonitor", array("sensor_id" => 6, "maxHumidityPercentage" => 20.0));
     $this->action('GET', 'notificationController@deleteNotification', null);
     $this->assertResponseStatus(500);
 }
예제 #2
0
 public function deleteNotification(Request $request)
 {
     $id = $request->input('id');
     $mix = MinMaxMonitor::where("id", "=", $id)->first();
     if ($mix == null) {
         return response("Error", 500);
     }
     $mix->user()->detach();
     $mix->delete();
     return response("Delete notification success", 200);
 }
예제 #3
0
            $notificationController->sentMonitorNotification("Alert!! : " . $id . " reach minimum temperature >" . $notificationCheck->maxCelsius . " celsius", $id);
        }
    }
    $temperature = new Temperature();
    $temperature->celsiusValue = $value;
    $Sensor->temperature()->save($temperature);
});
Route::get('sensingResister/{device_id}/{temperature}/{soilmoisture}/{light}/{humidity}', function ($id, $temp, $soil, $lux, $humid) {
    $DeviceBaseId = DB::table('sensingdevice')->where('device_id', $id)->value('id');
    $SensorPrimaryKey = DB::table('sensor')->where('sensingDevice_id', $DeviceBaseId)->value('id');
    $checkHourly = Light::where('sensor_id', '=', $SensorPrimaryKey)->count();
    $Sensor = Sensor::find($SensorPrimaryKey);
    $notificationController = new notificationController();
    $device = \App\SensingDevice::where("device_id", "=", $id)->first();
    $sensor = \App\Sensor::where("sensingDevice_id", "=", $device->id)->first();
    $notificationCheck = MinMaxMonitor::where("sensor_id", "=", $sensor->id)->first();
    if ($notificationCheck != null) {
        if ($notificationCheck->minHumidityPercentage != 0 && $notificationCheck->minHumidityPercentage > $humid) {
            $notificationController->sentMonitorNotification("Alert!! : " . $id . " reach minimum humidity <" . $notificationCheck->minHumidityPercentage . " %", $id);
        }
        if ($notificationCheck->maxHumidityPercentage != 0 && $notificationCheck->maxHumidityPercentage < $humid) {
            $notificationController->sentMonitorNotification("Alert!! : " . $id . " reach maximum humidity >" . $notificationCheck->maxHumidityPercentage . " %", $id);
        }
        if ($notificationCheck->minCelsius != 0 && $notificationCheck->minCelsius > $temp) {
            $notificationController->sentMonitorNotification("Alert!! : " . $id . " reach minimum temperature <" . $notificationCheck->minCelsius . " celsius", $id);
        }
        if ($notificationCheck->maxCelsius != 0 && $notificationCheck->maxCelsius < $temp) {
            $notificationController->sentMonitorNotification("Alert!! : " . $id . " reach minimum temperature >" . $notificationCheck->maxCelsius . " celsius", $id);
        }
        if ($notificationCheck->minSoilMoisture != 0 && $notificationCheck->minSoilMoisture > $soil) {
            $notificationController->sentMonitorNotification("Alert!! : " . $id . " reach minimum soil moisture <" . $notificationCheck->minSoilMoisture, $id);