I don’t think so there is any restriction. ArrayHelper is just a normal helper class and using it in models should be same as using it anywhere else in your code. Have used this helper across many classes without issues.
I think the problem is, you are using the use statement wrongly.
Move the use statement to before the class begins, and not within the class definition. This should work:
namespace app\models;
// MOVE YOUR USE STATEMENTS HERE
use yii\helpers\ArrayHelper;
class Category extends \yii\db\ActiveRecord {
// NO USE STATEMENTS HERE
public function getCategories()
{
return ArrayHelper::map(Category::find()->all(), 'id', 'name');
}
}