예제 #1
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     if ($request->input('plant_id') == null) {
         return response()->json("invalid", "500");
     }
     $user = User::where('username', '=', $request->input('username'))->first();
     $task = new TaskList();
     $task->description = $request->input('description');
     $task->date = date("Y-m-d", strtotime($request->input('date')));
     $task->time = $request->input('time');
     $task->status = "Remaining";
     $task->user_id = $user->id;
     $task->plant_id = $request->input('plant_id');
     $typeActivity[] = $request->input('type');
     $task->save();
     $worker = $request->input('worker');
     foreach ($worker as $uid) {
         if ($uid != "0") {
             $notificationControl = new notificationController();
             $task->workerMember()->attach($uid);
             $detailPlantPlot = Plant::where("id", "=", $task->plant_id)->with("plot")->first();
             $message = "" . $user->name . " " . $user->surname . "has assigned you a task!";
             $notificationControl->sentTaskToFarmWorker($message, $uid);
         }
     }
     foreach ($typeActivity as $id) {
         if ($id != "0") {
             $task->activityType()->attach($id);
         }
     }
     return $task;
     //
 }
예제 #2
0
            $notificationController->sentMonitorNotification("Alert!! : " . $id . " reach minimum temperature <" . $notificationCheck->minCelsius . " celsius", $id);
        }
        if ($notificationCheck->maxCelsius != 0 && $notificationCheck->maxCelsius < $value) {
            $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);