示例#1
0
 public function listHotspots($idUser, $name)
 {
     $HotsPotsGroups = DB::select("select DISTINCT H.id from hotspots as H " . "inner join hotspots_groups as HG ON H.id=HG.hotspots_id " . "where H.geocode={$idUser}");
     if ($HotsPotsGroups) {
         foreach ($HotsPotsGroups as $value) {
             $idHotspots[] = $value->id;
         }
         $Hostpots = Hostpots::whereNotIn('id', $idHotspots)->whereGeocode($idUser)->lists($name, 'id', 'geocode');
     } else {
         $Hostpots = Hostpots::whereGeocode($idUser)->lists($name, 'id', 'geocode');
     }
     return $Hostpots;
 }
 public function getEquipmentsFree(Request $request)
 {
     $groups_id = $request->input('groups_id');
     if (isset($groups_id) && !empty($groups_id)) {
         $dataGroup = \App\Models\Groups::find($groups_id);
         if ($dataGroup->customer_id != 0) {
             $newHostPots = new Hostpots();
             $data = $newHostPots->listHotspots($dataGroup->customer_id, 'name');
             foreach ($data as $value => $e) {
                 $dataInt[] = $value;
             }
         }
     }
     $HotsPotsGroups = DB::select("select DISTINCT H.id from hotspots as H " . "inner join hotspots_groups as HG ON H.id=HG.hotspots_id ");
     if (isset($dataInt) && count($dataInt) > 0) {
         if ($HotsPotsGroups) {
             foreach ($HotsPotsGroups as $value) {
                 $idHotspots[] = $value->id;
             }
             $Hostpots = Hostpots::whereNotIn('id', $idHotspots)->whereIn('id', $dataInt)->orWhere('geocode', 0)->lists('mac', 'id');
         } else {
             $Hostpots = Hostpots::whereIn('id', $dataInt)->whereIn('id', $dataInt)->orWhere('geocode', 0)->lists('mac', 'id');
         }
     } else {
         if ($HotsPotsGroups) {
             foreach ($HotsPotsGroups as $value) {
                 $idHotspots[] = $value->id;
             }
             $Hostpots = Hostpots::whereNotIn('id', $idHotspots)->whereGeocode(0)->lists('mac', 'id');
         } else {
             $Hostpots = Hostpots::whereGeocode(0)->lists('mac', 'id');
         }
     }
     return response()->json(array('state' => 1, 'msg' => 'ok', 'data' => $Hostpots));
 }