can't hasMany two table

Hi all,I use hasMany but show error "backend\modules\categories\models\Categories has no relation named "category_descriptions"."

public function getCategoryDescriptions() {

    return $this->hasMany(CategoryDescriptions::className(), ['category_id' => 'category_id']);



 * get category all.

 * @return data.


public function getAll(){

    $query = Categories::find();

    //$catalog = $query->all();

    $catalog = $query->joinWith('category_descriptions')->all();

    return $catalog;


you can help me !

It should be ‘categoryDescriptions’ and not ‘category_descriptions’.

$catalog = $query->joinWith('categoryDescriptions')->all();

You are doing it wrong. If you already have an object of class Category, then you can get all category descriptions simply by calling:

$category = Category::findOne($id);

$category->categoryDescriptions;//This will return you all descriptions for category with ID=$id

Read this:

thank you all.