loadMe(); $data["edit_by"] = $me->id; } return $data; } public function getProperty($name) { if($this->$name == null) { if($name == "attributes") { $this->attributes = []; $producttechAttributes = ProducttechAttributeModel::search(['producttech_id' => $this->id]); foreach($producttechAttributes as $pta) { $this->attributes[$pta->id] = $pta; } return $this->attributes; } $classname = ucfirst($name); $idfield = $name."_id"; $this->$name = new $classname($this->$idfield); if($this->$name->id) { return $this->$name; } else { return null; } } return $this->$name; } }