Yes you can do it with more flexible way. Create a common function.
function getWhere($yourModel, $select, $is_model_full_path=null, $condition_arr=null)
{
if(!$is_model_full_path){ // if your model exist in App directory
$yourModel ="App\\$yourModel";
}
if(!$condition_arr){
return $yourModel::all($select)->toArray();
}
return $App_models_yourModel::all($select)->where($condition_arr)->toArray();
}
Now you can call this method in different ways.
getWhere('User', ['id', 'name']); // with default path of model
getWhere('App\Models\User', ['id', 'name'], true); // with custom path of model
getWhere('User', ['id', 'name'], false, ['id', 1]); // with condition array
By the way I like to use such functions.