public static function getItemList($cat_id)
{
$models = NetItem::find()->where(['count_id' => $cat_id])->asArray()->all();
return ArrayHelper::map($models, 'id', 'name_en');
}
output: {244:Itemname, 245:Itemname2}
$out = [
['id'=>244, 'name'=>'Itemname'],
['id'=>245, 'name'=>'Itemname2'],
// and so on
];
public static function getItemList($cat_id)
{
return array_map(function (array $item) {
return [
'id' => $item['id'],
'name' => $item['name_en'];
];
}, NetItem::find()->where(['count_id' => $cat_id])->asArray()->all());
}