public function accommodationByOwner($owner_id) { $accomm = null; $accommodations = []; try { $accomm = AccommodationModel::all()->where('user_id', $owner_id); if ($accomm->count() == 0) { return null; } foreach ($accomm as $ac) { $a = new Accommodation(); $a->setID($ac->id); $a->setBaths($ac->bathrooms); $a->setBeds($ac->beds); $a->setCapacity($ac->capacity); $a->setCity($ac->city); $a->setDesc($ac->desc); $a->setInside($ac->inside); $a->setOutside($ac->outside); $a->setPhotos($this->allPhotos($ac->id)); $a->setPrice($ac->price_per_person); $a->setProvince($ac->province); $a->setTitle($ac->title); $a->setInitialDesc($ac->desc); $accommodations[] = $a; } } catch (QueryException $ex) { return null; } return $accommodations; }