public function loadFromRow(\stdClass $row) { $this->setId($row->id)->setTypeId($row->type_id)->setVin($row->vin)->setMakeId($row->make_id)->setModelId($row->model_id)->setInventoryNumber($row->inventory_number)->setYear($row->year)->setOdometerReading($row->odometer_reading)->setDescription($row->description)->setPrice($row->price)->setPricePostfix($row->price_postfix)->setIsVisible($row->is_visible)->setIsFeatured($row->is_featured)->setExterior($row->exterior)->setInterior($row->interior)->setCreatedAt($row->created_at)->setImportedAt($row->imported_at)->setUpdatedAt($row->updated_at); if (isset($row->make)) { $this->make = new Make(); $this->make->setId($row->make_id)->setTitle($row->make); } if (isset($row->model)) { $this->model = new Model(); $this->model->setId($row->model_id)->setTitle($row->model); } if (isset($row->type)) { $this->type = new AutoType(); $this->type->setId($row->type_id)->setTitle($row->type); } $features = json_decode($row->features, TRUE); if (!empty($features)) { foreach ($features as $f) { $feature = new AutoFeature(); $feature->setId($f['id'])->setFeatureId($f['feature_id'])->setFeatureTitle($f['feature_title'])->setValue($f['value'])->setCreatedAt($f['created_at'])->setUpdatedAt($f['updated_at']); $this->addFeature($feature); } } }