containerId = $containerId; $this->getSummary(); $this->getData(); } private function getSummary() { $URL = $this->apiSummary; $opt = []; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $URL); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $fields = http_build_query($opt); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $fields); $out = curl_exec($curl); $this->summary = json_decode($out, true); curl_close($curl); } private function getData() { $URL = $this->apiAll; $opt = []; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $URL); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $fields = http_build_query($opt); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $fields); $out = curl_exec($curl); $this->allObjects = json_decode($out, true); $this->types = $this->allObjects['values']['type']; $this->access = $this->allObjects['values']['access']; curl_close($curl); } public function setHouse($id) { $this->filter['bs'] = $id; } public function setRoom($id) { $this->room = $this->allObjects['data'][$id]; $this->filter['id'] = $id; } public function resetFilter() { $this->filter = []; } public function start() { $this->mode = 'select'; $this->filter = []; $this->getData(); } public function done() { $this->mode = 'selected'; $this->filter = []; } public function render() { $objs = []; if (count($this->filter)) { foreach ($this->allObjects['data'] as $key => $room) { if ($room['access'] != 0) { if (array_key_exists('id', $this->filter) && $this->filter['id'] !== null && $room['id'] != $this->filter['id']) { continue; } if (array_key_exists('bs', $this->filter) && $this->filter['bs'] !== null && $room['bs'] != $this->filter['bs']) { continue; } if (array_key_exists('type', $this->filter) && $this->filter['type'] !== null && $room['type'] != $this->filter['type']) { continue; } if (array_key_exists('min_area', $this->filter) && $this->filter['min_area'] !== null && $room['area'] < $this->filter['min_area']) { continue; } if (array_key_exists('max_area', $this->filter) && $this->filter['max_area'] !== null && $room['area'] > $this->filter['max_area']) { continue; } $room['mode'] = 'room'; $objs[] = $room; } } } else { foreach ($this->allObjects['values']['bs'] as $key => $house) { $objs[] = [ 'mode' => 'bs', 'id' => $house['id'], 'name' => $house['name'], ]; } } /*if (!$this->bs && !$this->room) { foreach ($this->allObjects['values']['bs'] as $key => $house) { $objs[] = [ 'mode' => 'bs', 'id' => $house['id'], 'name' => $house['name'], ]; } } elseif ($this->bs && !$this->room) { foreach ($this->allObjects['data'] as $key => $room) { if ($room['access'] != 0) { $room['mode'] = 'room'; $objs[] = $room; } } } elseif ($this->bs && $this->room) { foreach ($this->allObjects['data'] as $key => $room) { if ($room['id'] == $this->room['id']) { $room['mode'] = 'room'; $objs[] = $room; } } }*/ return view('plan7::livewire.selector', [ 'objs' => $objs ]); } }