public function listHotspots(Request $request) { try { $idGroup = $request->input('groups_id'); $dataGroup = Groups::find($idGroup); $exercise = new Hostpots(); if ($dataGroup->customer_id == Auth::customer()->user()->id) { $data = $exercise->listHotspots($dataGroup->customer_id, 'email_owner'); } else { $data = $exercise->listHotspots($dataGroup->customer_id, 'mac'); } $return = array('state' => 1, 'msg' => 'ok', 'data' => $data); } catch (Exception $exc) { $return = array('state' => 0, 'msg' => $exc->getMessage()); } return response()->json($return); }
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)); }