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?