コード例 #1
0
ファイル: UrlRule.php プロジェクト: black-lamp/yii2-articles
 private function findCategoryBySeoUrl($seoUrl, $parentId, $options = [])
 {
     $categoriesSeoData = SeoData::find()->where(['entity_name' => CategoryTranslation::className(), 'seo_url' => $seoUrl])->all();
     if ($categoriesSeoData) {
         foreach ($categoriesSeoData as $categorySeoData) {
             if ($category = Category::find()->joinWith('translations translation')->where(array_merge(['translation.id' => $categorySeoData->entity_id, 'parent_id' => $parentId, 'translation.language_id' => $this->currentLanguage->id], $options))->one()) {
                 return $category;
             }
         }
     }
     return null;
 }
コード例 #2
0
ファイル: Category.php プロジェクト: black-lamp/yii2-articles
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTranslations()
 {
     return $this->hasMany(CategoryTranslation::className(), ['category_id' => 'id']);
 }