How to select column i need from relation table in AR?

It’s code of my controller:

$arr = Menu::find()->with([
            'link' => function ($query) {
                $query->select('menu_id, role_id');
            }
        ])->asArray()->all();

It’s code of my model:

public function getLink()
{
    return $this->hasMany(Menu_role::className(), ['menu_id' => 'id']);
}

Problem is i must do select menu_id(it the key that bind Menu and Menu_role table) always.
In instance i need to select title from table, but i MUST with title select menu_id that i don’t need.

Is there any other way to select column i need without key or maybe i can change my code a bit for that somehow?

Hi kotcich, have you tried adding these columns to the select? Like this:

$arr = Menu::find()
    ->select([Menu::tableName() .'.*', 'link.menu_id', 'link.role_id'])
    ->with([
        'link' => function ($query) {
            $query->select('menu_id, role_id');
        }
    ])->asArray()->all();

If that’s not your issue, could you please try explaining a different way, please?