/**
  * Given active record class name returns new model instance.
  *
  * @param string $className active record class name.
  *
  * @return \Database\ActiveRecord\Record active record model instance.
  *
  * @since 1.1.14
  */
 protected function getModel($className)
 {
     return \Database\ActiveRecord\Record::model($className);
 }
 /**
  * Returns the static model of the specified AR class.
  * Please note that you should have this exact method in all your Record descendants!
  * @param string $className active record class name.
  * @return CargoPacking the static model class
  */
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
Example #3
0
 /**
  * Returns the text label for the specified attribute.
  * This method overrides the parent implementation by supporting
  * returning the label defined in relational object.
  * In particular, if the attribute name is in the form of "post.author.name",
  * then this method will derive the label from the "author" relation's "name" attribute.
  * @param string $attribute the attribute name
  * @return string the attribute label
  * @see generateAttributeLabel
  * @since 1.1.4
  */
 public function getAttributeLabel($attribute)
 {
     $labels = $this->attributeLabels();
     if (isset($labels[$attribute])) {
         return $labels[$attribute];
     } elseif (strpos($attribute, '.') !== false) {
         $segs = explode('.', $attribute);
         $name = array_pop($segs);
         $model = $this;
         foreach ($segs as $seg) {
             $relations = $model->getMetaData()->relations;
             if (isset($relations[$seg])) {
                 $model = Record::model($relations[$seg]->className);
             } else {
                 break;
             }
         }
         return $model->getAttributeLabel($name);
     } else {
         return $this->generateAttributeLabel($attribute);
     }
 }