Пример #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
 /**
  * @return array - list of immediate child categories
  */
 public function getCategories()
 {
     return $this->hasMany(Category::className(), ['parentId' => 'id']);
 }