コード例 #1
1
 /**
  * Relation to model translations
  * @return ActiveQuery
  * @since 2.0.0
  */
 public function getTranslations()
 {
     return $this->owner->hasMany($this->translateClassName, [$this->translateForeignKey => $this->ownerPrimaryKey]);
 }
コード例 #2
0
 public function hasMany($class, $link, $alias = null)
 {
     $query = parent::hasMany($class, $link);
     if ($alias == null) {
         $alias = lcfirst(str_replace('_', '', $class::tableName()));
     }
     return $query->from([$alias => $class::tableName()]);
 }
コード例 #3
0
 /**
  * Relation to model translations
  *
  * @return ActiveQuery
  */
 public function getTranslations()
 {
     return $this->owner->hasMany($this->translationModelName, [$this->translationOwnerField => $this->ownerPrimaryKey]);
 }
コード例 #4
0
ファイル: ActiveRecord.php プロジェクト: tsyrya/mybriop
 /**
  * @inheritdoc
  */
 public function hasMany($class, $link)
 {
     return parent::hasMany($this->replaceRelatedClass($class), $link);
 }
コード例 #5
0
ファイル: ActiveRecord.php プロジェクト: dawei101/plants
 public function hasMany($class, $link)
 {
     $rclass = $this->replaceClassWithCurrentPathOne($class);
     return parent::hasMany($rclass, $link);
 }
コード例 #6
0
 /**
  * Declares a `has-many` relation.
  * @param string $class the class name of the related record
  * @param array $link the primary-foreign key constraint. The keys of the array refer to
  * the attributes of the record associated with the `$class` model, while the values of the
  * array refer to the corresponding attributes in **this** AR class.
  * adjust the result to use the primary key as the array key
  * @return ActiveQueryInterface the relational query object.
  */
 public function hasMany($class, $link)
 {
     /* @var $class ActiveRecordInterface */
     /* @var $query ActiveQuery */
     $query = parent::hasMany($class, $link);
     if ($query->multiple) {
         $keys = $class::primaryKey();
         if (count($keys) === 1) {
             $query->indexBy = $keys[0];
         } elseif (count($keys) === 2) {
             $query->indexBy = $keys[1];
         }
     }
     return $query;
 }