コード例 #1
0
 /**
  * @return array - Category associated with parent
  */
 public function getCategories()
 {
     return $this->hasMany(Category::className(), ['id' => 'categoryId'])->viaTable(CoreTables::TABLE_MODEL_CATEGORY, ['parentId' => 'id'], function ($query) {
         $modelCategory = CoreTables::TABLE_MODEL_CATEGORY;
         $query->onCondition(["{$modelCategory}.parentType" => $this->categoryType]);
     });
 }
コード例 #2
0
 /**
  * @return Category - associated category
  */
 public function getCategory()
 {
     return $this->hasOne(Category::className(), ['id' => 'categoryId']);
 }
コード例 #3
0
ファイル: Category.php プロジェクト: cmsgears/module-core
 /**
  * @return array - list of immediate child categories
  */
 public function getCategories()
 {
     return $this->hasMany(Category::className(), ['parentId' => 'id']);
 }