Example #1
0
 protected function setOne($property)
 {
     // Normalize vars
     $property = (object) $property;
     $class = $property->type;
     // Recognize address
     $address = "{$property->Addr} {$property->Zip} Canada";
     $recognized = \Vividcrestrealestate\Core\Libs\Address::recognize($address);
     // Save main data
     $property_id = parent::setOne((object) ['mls_id' => $property->Ml_num, 'creation_date' => date("Y-m-d H:i:s"), 'publish_date' => date("Y-m-d H:i:s", strtotime($property->Timestamp_sql)), 'country' => $recognized->country, 'city' => $recognized->city, 'sublocality' => $recognized->sublocality, 'neighborhood' => $recognized->neighborhood, 'postal_code' => $recognized->postal_code, 'address' => $recognized->address, 'latitude' => $recognized->latitude, 'longitude' => $recognized->longitude, 'bedrooms' => isset($property->Br) ? $property->Br : "0", 'bathrooms' => $property->Bath_tot, 'type' => $class, 'deal_type' => $property->Lp_dol > 10000 ? "buy" : "rent", 'price' => $property->Lp_dol, 'size' => !empty($property->Sqft) ? $property->Sqft : (!empty($property->Tot_area) ? $property->Tot_area : "0"), 'description' => $property->Ad_text, 'main_image' => !empty($property->main_image) ? $property->main_image : get_template_directory_uri() . "/images/property.jpg"]);
     // Save additional data
     if (!empty($property_id)) {
         $PropertInfo = new PropertyInfo();
         $fields_accordance = (new FieldsAccordance())->get(["`class`='{$class}'"]);
         foreach ($fields_accordance as $accordance) {
             $value = $property->{$accordance->field_name};
             if (!empty($value)) {
                 $PropertInfo->set((object) ['property_id' => $property_id, 'title' => $accordance->field_title, 'key' => $accordance->field_name, 'value' => $value]);
             }
         }
     }
     return $property_id;
 }
 /**
  * Gets a property by its name.
  * 
  * @param string $name
  * @return PropertyInfo
  * @throws ReflectionException A reflection exception will be thrown, if the property does not exist.
  */
 public function getProperty($name)
 {
     $m = $this->getReflectionClass()->getProperty($name);
     return PropertyInfo::__internal_create($this, $m);
 }