Esempio n. 1
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMetaRelation()
 {
     $query = $this->owner->hasOne($this->metaClass, ['entity_id' => 'id']);
     if ($this->ownerType) {
         $query->where(['entity_type' => $this->ownerType]);
     }
     return $query;
 }
 /**
  * Relation to model translation
  *
  * @param $language
  *
  * @return ActiveQuery
  * @since 2.0.0
  */
 public function getTranslation($language = null)
 {
     if ($language == null) {
         $language = $this->currentLanguage;
     }
     return $this->owner->hasOne($this->translateClassName, [$this->translateForeignKey => $this->ownerPrimaryKey])->where([$this->languageField => $language]);
 }
Esempio n. 3
0
 public function hasOne($class, $link, $alias = null)
 {
     $query = parent::hasOne($class, $link);
     if ($alias == null) {
         $alias = lcfirst(str_replace('_', '', $class::tableName()));
     }
     return $query->from([$alias => $class::tableName()]);
 }
Esempio n. 4
0
 public function getSeo()
 {
     return $this->owner->hasOne(SeoText::className(), ['item_id' => $this->owner->primaryKey()[0]])->where(['class' => $this->owner->className()]);
 }
Esempio n. 5
0
 /**
  * Relation to model translation
  *
  * @param $locale
  * @return ActiveQuery
  */
 public function getTranslation($locale = null)
 {
     $locale = $locale ?: Yii::$app->language;
     return $this->owner->hasOne($this->translationModelName, [$this->translationOwnerField => $this->ownerPrimaryKey])->from(['content' => call_user_func([$this->translationModelName, 'tableName'])])->innerJoin(['lang' => Language::tableName()])->where('lang.locale = :locale', [':locale' => $locale])->andWhere('content.' . $this->owner->getDb()->quoteColumnName($this->languageField) . ' = lang.id');
 }
 /**
  * @return File\Query
  */
 public function getFile()
 {
     return $this->owner->hasOne(File::className(), ['id' => $this->attribute]);
 }
Esempio n. 7
0
 /**
  * @inheritdoc
  */
 public function hasOne($class, $link)
 {
     return parent::hasOne($this->replaceRelatedClass($class), $link);
 }
Esempio n. 8
0
 public function hasOne($class, $link)
 {
     $rclass = $this->replaceClassWithCurrentPathOne($class);
     return parent::hasOne($rclass, $link);
 }