Clean Up
This commit is contained in:
		| @@ -1,34 +1,33 @@ | |||||||
| <?php | <?php | ||||||
|  |  | ||||||
| class RoomsApi extends ApiController{ | class RoomsApi extends ApiController{ | ||||||
|  | 	 | ||||||
| 	public function default(){ | 	public function default(){ | ||||||
| 		//$this->requireAuth(); | 		//$this->requireAuth(); | ||||||
| 		$response = []; | 		$response = []; | ||||||
| 		$roomIds = []; | 		$roomIds = []; | ||||||
| 		$roomsData = RoomManager::getRoomsDefault(); | 		$roomsData = RoomManager::getRoomsDefault(); | ||||||
|  | 		 | ||||||
| 		foreach ($roomsData as $roomKey => $room) { | 		foreach ($roomsData as $roomKey => $room) { | ||||||
| 			$roomIds[] = $room['room_id']; | 			$roomIds[] = $room['room_id']; | ||||||
| 		} | 		} | ||||||
|  | 		 | ||||||
| 		$subDevicesData = SubDeviceManager::getSubdevicesByRoomIds($roomIds); | 		$subDevicesData = SubDeviceManager::getSubdevicesByRoomIds($roomIds); | ||||||
|  | 		 | ||||||
| 		foreach ($roomsData as $roomKey => $roomData) { | 		foreach ($roomsData as $roomKey => $roomData) { | ||||||
| 			if ($roomData['device_count'] != 0){ | 			if ($roomData['device_count'] == 0) continue; | ||||||
| 				$response[] = [ | 			$response[] = [ | ||||||
| 					'room_id' => $roomData['room_id'], | 				'room_id' => $roomData['room_id'], | ||||||
| 					'name' => $roomData['name'], | 				'name' => $roomData['name'], | ||||||
| 					'widgets' => isset($subDevicesData[$roomData['room_id']]) ? $subDevicesData[$roomData['room_id']] : [], | 				'widgets' => isset($subDevicesData[$roomData['room_id']]) ? $subDevicesData[$roomData['room_id']] : [], | ||||||
| 				]; | 			]; | ||||||
| 			} |  | ||||||
| 		} | 		} | ||||||
| 		$this->response($response); | 		$this->response($response); | ||||||
| 	} | 	} | ||||||
|  | 	 | ||||||
| 	public function update($roomId){ | 	public function update($roomId){ | ||||||
| 		//$this->requireAuth(); | 		//$this->requireAuth(); | ||||||
|  | 		 | ||||||
| 		$subDevicesData = SubDeviceManager::getSubdevicesByRoomIds([$roomId]); | 		$subDevicesData = SubDeviceManager::getSubdevicesByRoomIds([$roomId]); | ||||||
| 		$this->response($subDevicesData); | 		$this->response($subDevicesData); | ||||||
| 	} | 	} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user