Exemplo n.º 1
0
 public function allAcomByCity($city)
 {
     $am = new AccommodationModel();
     $accomm = null;
     $accommodations = [];
     try {
         $accomm = DB::table('accommodations')->where('province', $city)->orWhere('city', $city)->paginate(5);
         if (count($accomm) == 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($am->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;
 }
 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;
 }