public function getAttribute($field) { if ($field == 'adv_number') { return $this->adv_number; } return parent::getAttribute($field); }
public function getAttribute($name) { if ($name === 'cp.name') { return $this->cp->name; } else { return parent::getAttribute($name); } }
public function getAttribute($field) { switch ($field) { case 'adv.name': return $this->advertise->name; case 'channel.name': return $this->channel->name; case 'cp.name': return $this->advertise->cp->name; case 'uploader.name': return $this->uploader->name; /*11-12*/ /*11-12*/ case 'income_price': return sprintf("%01.2f", $this->income_price); case 'price': return sprintf("%01.2f", $this->price); case 'profit_margin': return sprintf("%01.2f", $this->profit_margin) . '%'; case 'running_account': return sprintf("%01.2f", $this->running_account); case 'total_price': return sprintf("%01.2f", $this->total_price); case 'profit': return sprintf("%01.2f", $this->profit); /*end*/ } return parent::getAttribute($field); }
public function getAttribute($name) { $value = parent::getAttribute($name); if (is_array($value)) { $value = implode(",", $value); } return $value; }
/** * Returns the named attribute value. * Recognizes linked attributes and looks them up with {@link getLinkedAttribute()} * @param string $name the attribute name * @param bool $renderFlag * @param bool $makeLinks If the render flag is set, determines whether to render attributes * as links * @return mixed the attribute value. Null if the attribute is not set or does not exist. * @see hasAttribute */ public function getAttribute($name, $renderFlag = false, $makeLinks = false) { $nameParts = explode('.', $name); // check for a linked attribute (eg. "account.assignedTo") if (count($nameParts) > 1) { // We have a complicated link like "account.primaryContact.email" $linkField = array_shift($nameParts); // Remove the current model $linkModel = $this->getLinkedModel($linkField); $name = implode('.', $nameParts); // Put the name back together e.g. primaryContact.email if (isset($linkModel)) { return $linkModel->getAttribute($name, $renderFlag); } else { $fieldInfo = $this->getField($linkField); // If it's an assignment field, check the Profile model if ($fieldInfo instanceof Fields && $fieldInfo->type == 'assignment') { $profRecord = X2Model::model('Profile')->findByAttributes(array('username' => $this->{$linkField})); if (isset($profRecord)) { return $profRecord->getAttribute($name, false); } } } } else { if ($renderFlag) { return $this->renderAttribute($name, $makeLinks); } else { return parent::getAttribute($name); } } return null; }
public function getAttribute($field) { switch ($field) { case 'cp.name': return $this->cp ? $this->cp->name : ''; case 'adv.name': return $this->advertise ? $this->advertise->name : ''; case 'channel.name': return $this->channel ? $this->channel->name : ''; } return parent::getAttribute($field); }
/** * This method is used to at create/copy or move. If the last $inherit attribute is true * the nodes under current and current also will inherit the values from the new parent. * @param CActiveRecord $current node that is created/copied or moved * @param CActiveRecord $parent the new parent in either senario */ public function inheritvalues($current, $parent) { // $differentparent = $parent->getAttribute($this->identity)!=$current->parent()->getAttribute($this->identity); // if ( $differentparent ) { foreach ($this->inherit as $attr) { $current->setAttribute($attr, $parent->getAttribute($attr)); } $current->saveNode(); $descendants = $current->descendants()->findAll(); foreach ($descendants as $i => $node) { foreach ($this->inherit as $attr) { $node->setAttribute($attr, $parent->getAttribute($attr)); } $node->saveNode(); } //} }