containerId = $containerId; $this->getData(); } private function getData() { $URL = $this->api; $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->bs = $id; $this->room = null; } public function setRoom($id) { $this->room = $this->allObjects['data'][$id]; } public function start() { $this->mode = 'select'; $this->getData(); } public function done() { $this->mode = 'selected'; $this->bs = null; $this->room = null; } public function render() { $objs = []; 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 ]); } }