/** * */ public function fire() { // get ID for next step $selectedResource = $this->pickResource(); $this->info('Retrieving resource data for ' . $selectedResource->ResourceID); // get meta Classes for Resource // now we need to know what tables to get $selectedClasses = $this->pickClasses($selectedResource->ResourceID); // we're going to get metadata to retrieve $fieldMetadata = []; // loop over selection and get table foreach ($selectedClasses as $class) { // pull meta for table $metaTable = $this->rets->getTable($selectedResource->ResourceID, (string) $class->ClassName); // time to create date $fieldMetadata = array_merge($fieldMetadata, $this->parseFields('class_' . (string) $class->ClassName, $metaTable)); } // pull metadata if (!empty($fieldMetadata)) { $this->info('We need to pull data for ' . count($fieldMetadata) . ' ' . \Str::plural('field', count($fieldMetadata))); foreach ($fieldMetadata as $meta_id => $id) { $fieldData = $this->rets->getFieldMetadata($selectedResource->ResourceID, $meta_id); try { RetsField::createFromXml($fieldData[0]); } catch (\Exception $e) { $this->error($e->getMessage()); } } } else { $this->info('Looks like we not able to find a single field that requires metadata look up. Skipping.'); } }
/** * Get a plain attribute (not a relationship). * * @param string $key * * @return mixed */ protected function getAttributeValue($key) { $value = $this->getAttributeFromArray($key); // If the attribute has a get mutator, we will call that then return what // it returns as the value, which is useful for transforming values on // retrieval from the model to a form that is more useful for usage. if ($this->hasGetMutator($key)) { return $this->mutateAttribute($key, $value); } elseif (in_array($key, $this->getDates())) { if ($value) { return $this->asDateTime($value); } } elseif (!is_null(\Config::get('rets.rets_property.' . $key . '.matadata_id', null))) { $ids = explode(',', $value); $values = RetsField::where('lookup_id', \Config::get('rets.rets_property.' . $key . '.matadata_id', null))->whereIn('id', $ids)->get(); if ($values->isEmpty()) { return $value; } return $values; } return $value; }