本模型采用 `adminCategoryTree` 方法
```
<?php
namespace app\agent\model;
use think\Model;
use tree\Tree;
class AgentCategoryModel extends Model
{
/**
* 生成分类 select树形结构
* @param int $selectId 需要选中的分类 id
* @param int $currentCid 需要隐藏的分类 id
* @return string
*/
public function adminCategoryTree($selectId = 0, $currentCid = 0)
{
$where = ['delete_time' => 0];
if (!empty($currentCid)) {
$where['id'] = ['neq', $currentCid];
}
$categories = $this->order("list_order ASC")->where($where)->select()->toArray();
$tree = new Tree();
$tree->icon = [' │', ' ├─', ' └─'];
$tree->nbsp = ' ';
$newCategories = [];
foreach ($categories as $item) {
$item['selected'] = $selectId == $item['id'] ? "selected" : "";
array_push($newCategories, $item);
}
$tree->init($newCategories);
$str = '<option value=\"{$id}\" {$selected}>{$spacer}{$name}</option>';
$treeStr = $tree->getTree(0, $str);
return $treeStr;
}
}
```